Images with width and height
There is a way to insert an image inside of the html code
with width and height already? I mean, now, if I want to insert an
image at the code, goes only <img src="images/test.gif" /> I
d like that if I insert an image it goes as: <img
src="images/canto_topo.gif" width="8" height="29" />
is possible in dreamwaver to do that?
Thanks!
Vismona
If you insert the image using the "Insert Image" function, DW
will
automatically insert the width and height.
Or, if you'd rather insert them the way you are, in the
Property Inspector
on the far left, click the dimensions next to the Image
field, and DW will
automatically add (or correct) the width and height.
Hope that helps,
Patty Ayers | www.WebDevBiz.com
Free Articles on the Business of Web Development
Web Design Contract, Estimate Request Form, Estimate
Worksheet
"Vismona" <[email protected]> wrote in
message
news:gc60ut$nmv$[email protected]..
> There is a way to insert an image inside of the html
code with width and
> height
> already? I mean, now, if I want to insert an image at
the code, goes only
> <img
> src="images/test.gif" /> I d like that if I insert an
image it goes as:
> <img
> src="images/canto_topo.gif" width="8" height="29" />
>
> is possible in dreamwaver to do that?
>
> Thanks!
> Vismona
>
Similar Messages
-
Revision: 4793
Author: [email protected]
Date: 2009-02-02 11:20:06 -0800 (Mon, 02 Feb 2009)
Log Message:
Fix bug SDK-17734 Path with width and height set different than path data has incorrect bounds
Fix: When calculating the bounds position we should take into account the implicit scaling factor actualSize/naturalSize. Also did some refactoring, getting rid of the protected method calculateTopLeft.
QE Notes: None
Doc Notes: None
Bugs: SDK-17734
Reviewer: Ryan
tests: mustella gumbo/layout/GraphicElement
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-17734
http://bugs.adobe.com/jira/browse/SDK-17734
Modified Paths:
flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/Ellipse.as
flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/Path.as
flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/graphicsClasses/GraphicElement.a sThank you so much for replying.
Yes I have removed and reinstalled WMP.
I had good results with the PD6 application installed on the default path onto the C: drive with the one exception that if the application was launched by accident and the user data path was not available, the PD6 application would blow away my custom user path registry settings. Now that I know what they are I have made a .reg file to repair my registry to my desired user data paths.
Installing the application on the removable drive appeared to help prevent me from launching the application by accident and overwriting my registry with default user paths.
So which is the less of the two evils?
If the application directory is not available, windows media player still tries to launch the .msi for installing PD6.
If I install the application to the C: drive but the user data to the removable drive, launching the PD6 application without the user data drive will still corrupt my registry settings for a user data path.
Both these issues seem like a logical (if not easy) fix that should be done in the PD6 application and installation package. I mean really, cannot anyone tell me why windows media player is checking the PD6 application directory? Why in PD4 did we have an option control for setting the user data path from the PD4 application? Why is this option not in the PD6 application, just the installer?
I am given a choice during installation to move the user data to another non default location. Why else would this be provided if not to accommodate my kind of request to store the user data into an alternate location other than “My Document”. Certainly Palm is not trying to force the users on how to protect and store their personal data?
Post relates to: Centro (Verizon) -
Get image properties (width and height)
Hi there,
Does anyone know if there is a way that I could get the width and height of an image to be displayed in a JSP.Image has methods to get the width & height.
-
Draw rotated image to given width and height
Problem, if an image where width and height aren't equal is rotated and drawn again, the image is not drawn (stretched) to the full width.
Below is an example to illustrate my problem. The top image is stretched to the full width, the other aint.
Example picture: http://www.google.nl/intl/nl_nl/images/logo.gif
What am I doing wrong??
Greet Retep
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
public class Test2 extends Frame{
public static void main(String[] args)
try {
new Test2();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
public Test2() {
super("Rotate picture");
add(new RotateTest());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
setFont(new Font("default", Font.PLAIN, 24));
setSize(300, 300);
setVisible(true);
class RotateTest extends JComponent {
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
try {
BufferedImage image = ImageIO.read(new BufferedInputStream(new FileInputStream("C:/logo.gif")));
AffineTransform affineTransForm = new AffineTransform();
affineTransForm.rotate(Math.toRadians(270), image.getWidth(), 0);
//flip
//affineTransForm.translate(0, image.getHeight());
//affineTransForm.scale(1, -1);
BufferedImageOp bufferedImageOp = new AffineTransformOp(affineTransForm,
AffineTransformOp.TYPE_BICUBIC);
BufferedImage image2 = bufferedImageOp.filter(image, null);
// BufferedImage tempImage = new BufferedImage(image.getWidth(),image.getHeight(), image2.getType());
// Graphics2D graphics2D = tempImage.createGraphics();
// graphics2D.drawImage(image2, 0, 0, null);
// graphics2D.dispose();
g2d.drawImage(image, 5, 15, 280, 50, null);
g2d.drawImage(image2, 5, 70, 280, 50, null);
//g2d.drawImage(tempImage, 5, 125, 280, 50, null);
//g2d.drawImage(image, affineTransForm, null);
g2d.drawRect(5, 15, 280, 50);
g2d.drawRect(5, 70, 280, 50);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}Let's see if this helps...
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
public class T2Rx extends Frame {
public static void main(String[] args) {
try {
new T2Rx();
} catch (Exception e) {
e.printStackTrace();
public T2Rx() {
super("Rotate picture");
add(new RotateTest());
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
setFont(new Font("default", Font.PLAIN, 24));
setSize(300, 375);
setLocation(200,200);
setVisible(true);
class RotateTest extends JComponent {
BufferedImage image;
RotateTest() {
// You only need to do this one time. Save the image in a
// a member variable so you can access it whenever you want.
try {
image = ImageIO.read(new BufferedInputStream(
new FileInputStream("logo.gif")));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
int w = getWidth();
int h = getHeight();
BufferedImage scaled = scaleTo(image, 280, 50);
int iw = scaled.getWidth();
int ih = scaled.getHeight();
double x = (w - iw)/2.0;
double y = 1;
g2.drawImage(scaled, (int)x, (int)y, this);
g2.draw(new Rectangle2D.Double(x, y, iw, ih));
double theta = Math.PI*3/2;
x = (w - ih)/2.0;
y = (ih + iw)/2.0 + 1;
AffineTransform at = AffineTransform.getTranslateInstance(x, y);
at.rotate(theta, iw/2.0, ih/2.0);
g2.drawRenderedImage(scaled, at);
g2.draw(at.createTransformedShape(new Rectangle2D.Double(0, 0, iw, ih)));
private BufferedImage scaleTo(BufferedImage src, int w, int h) {
//System.out.printf("type = %d%n", src.getType());
// This type gives a better appearance after scaling.
int type = BufferedImage.TYPE_INT_RGB;
BufferedImage out = new BufferedImage(w, h, type);
Graphics2D g2 = out.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.setBackground(getBackground());
//java.awt.Color.pink); // just checking
g2.clearRect(0, 0, w, h);
double xScale = (double)w/src.getWidth();
double yScale = (double)h/src.getHeight();
double scale = Math.min(xScale, yScale); // scale to fit
//Math.max(xScale, yScale); // scale to fill
double x = (w - scale*src.getWidth())/2;
double y = (h - scale*src.getHeight())/2;
AffineTransform at = AffineTransform.getTranslateInstance(x, y);
at.scale(scale, scale);
g2.drawRenderedImage(src, at);
g2.dispose();
return out;
} -
Java returning incorrect values for width and height of a Tiff image
I have some TIFF images (sorry, I cannot post them b/c of there confidential nature) that are returning the incorrect values for the width and height. I am using Image.getWidth(null) and have tried the relevant methods from BufferedImage. When I open the same files in external viewers (Irfanview, MS Office Document Imaging) they look fine and report the "correct" dimensions. When I re-save the files, my code works fine. Obviously, there is something wrong with the files, but why would the Java code fail and not the external viewers? Is there some way I can detect file problems?
Here is the code, the relevant section is in the print() routine.
* ImagePrinter.java
* Created on Feb 27, 2008
* Created by tso1207
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.ImageInputStream;
import com.shelter.io.FileTypeIdentifier;
public class ImagePrinter extends FilePrintable
private final ImageReader _reader;
private final int _pageCount;
private final boolean _isTiff;
//for speed we will hold current page info in memory
private Image _image = null;
private int _imgWidth = 0;
private int _imgHeight = 0;
private int _currentPage = -1;
public ImagePrinter(File imageFile) throws IOException
super(imageFile);
ImageInputStream fis = new FileImageInputStream(getFile());
Iterator readerIter = ImageIO.getImageReaders(fis);
ImageReader reader = null;
while (readerIter.hasNext())
reader = (ImageReader) readerIter.next();
reader.setInput(fis);
_reader = reader;
int pageCount = 1;
String mimeType = FileTypeIdentifier.getMimeType(imageFile, true);
if (mimeType.equalsIgnoreCase("image/tiff"))
_isTiff = true;
pageCount = reader.getNumImages(true);
else
_isTiff = false;
_pageCount = pageCount;
public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
throws java.awt.print.PrinterException
int drawX = 0, drawY = 0;
double scaleRatio = 1;
if (getCurrentPage() != (pageIndex - getPageOffset()))
try
setCurrentPage(pageIndex - getPageOffset());
setImage(_reader.read(getCurrentPage()));
setImgWidth(getImage().getWidth(null));
setImgHeight(getImage().getHeight(null));
catch (IndexOutOfBoundsException e)
return NO_SUCH_PAGE;
catch (IOException e)
throw new PrinterException(e.getLocalizedMessage());
if (!_isTiff && getImgWidth() > getImgHeight())
pf.setOrientation(PageFormat.LANDSCAPE);
else
pf.setOrientation(PageFormat.PORTRAIT);
Graphics2D g2 = (Graphics2D) g;
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.setClip(0, 0, (int) pf.getImageableWidth(), (int) pf.getImageableHeight());
scaleRatio =
(double) ((getImgWidth() > getImgHeight())
? (pf.getImageableWidth() / getImgWidth())
: (pf.getImageableHeight() / getImgHeight()));
//check the scale ratio to make sure that we will not write something off the page
if ((getImgWidth() * scaleRatio) > pf.getImageableWidth())
scaleRatio = (pf.getImageableWidth() / getImgWidth());
else if ((getImgHeight() * scaleRatio) > pf.getImageableHeight())
scaleRatio = (pf.getImageableHeight() / getImgHeight());
int drawWidth = getImgWidth();
int drawHeight = getImgHeight();
//center image
if (scaleRatio < 1)
drawX = (int) ((pf.getImageableWidth() - (getImgWidth() * scaleRatio)) / 2);
drawY = (int) ((pf.getImageableHeight() - (getImgHeight() * scaleRatio)) / 2);
drawWidth = (int) (getImgWidth() * scaleRatio);
drawHeight = (int) (getImgHeight() * scaleRatio);
else
drawX = (int) (pf.getImageableWidth() - getImgWidth()) / 2;
drawY = (int) (pf.getImageableHeight() - getImgHeight()) / 2;
g2.drawImage(getImage(), drawX, drawY, drawWidth, drawHeight, null);
g2.dispose();
return PAGE_EXISTS;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since version XXX
* @return
public int getPageCount()
return _pageCount;
public void destroy()
setImage(null);
try
_reader.reset();
_reader.dispose();
catch (Exception e)
System.gc();
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @return
public Image getImage()
return _image;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @return
public int getImgHeight()
return _imgHeight;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @return
public int getImgWidth()
return _imgWidth;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @param image
public void setImage(Image image)
_image = image;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @param i
public void setImgHeight(int i)
_imgHeight = i;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @param i
public void setImgWidth(int i)
_imgWidth = i;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @return
public int getCurrentPage()
return _currentPage;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since Mar 25, 2008
* @param i
public void setCurrentPage(int i)
_currentPage = i;
}Edited by: jloyd01 on Jul 3, 2008 8:26 AMFigured it out. The files have a different vertical and horizontal resolutions. In this case the horizontal resolution is 200 DPI and the vertical is 100 DPI. The imgage width and height values are based on those resolution values. I wrote a section of code to take care of the problem (at least for TIFF 6.0)
private void setPageSize(int pageNum) throws IOException
IIOMetadata imageMetadata = _reader.getImageMetadata(pageNum);
//Get the IFD (Image File Directory) which is the root of all the tags
//for this image. From here we can get all the tags in the image.
TIFFDirectory ifd = TIFFDirectory.createFromMetadata(imageMetadata);
double xPixles = ifd.getTIFFField(256).getAsDouble(0);
double yPixles = ifd.getTIFFField(257).getAsDouble(0);
double xRes = ifd.getTIFFField(282).getAsDouble(0);
double yres = ifd.getTIFFField(283).getAsDouble(0);
int resUnits = ifd.getTIFFField(296).getAsInt(0);
double imageWidth = xPixles / xRes;
double imageHeight = yPixles / yres;
//if units are in CM convert ot inches
if (resUnits == 3)
imageWidth = imageWidth * 0.3937;
imageHeight = imageHeight * 0.3937;
//convert to pixles in 72 DPI
imageWidth = imageWidth * 72;
imageHeight = imageHeight * 72;
setImgWidth((int) Math.round(imageWidth));
setImgHeight((int) Math.round(imageHeight));
setImgAspectRatio(imageWidth / imageHeight);
} -
Finding the width and height of an image
Hi...
i have a path to an image "images/me.gif" and i'm trying to find its width and height.. am trying to use javax.swing.ImageIcon but it refuses to recognise the constructor with just the filename (string) parameter, and needs a URL to the file... anyone knows what i'm doing wrong??? is this the wrong class that i'm using...!??!?!?!?!?String filename = "images/me.gif";
Image myImage = carregarImagem(filename);
System.out.println(myImage.getWidth(this));
System.out.println(myImage.getHeight(this));
* M�todo que carrega imagens na mem�ria, a partir da URL onde o
* applet est� sendo carregado. O uso de um 'mediaTracker' � fundamental para
* evitar problemas quanto � velocidade de carga de uma imagem. Se voc� n�o
* usar um mediaTracker, o seu c�digo pode tentar usar uma imagem antes dela
* estar plenamente carregada na mem�ria, o que causaria um erro de execu��o.
* @param nomeDaImagem O nome da imagem a ser carregada
* @return A imagem requisitada ou null caso n�o haja tal imagem na url do applet
public Image carregarImagem(String nomeDaImagem)
try
Image imagem = getImage(getDocumentBase(), nomeDaImagem);
MediaTracker carregador = new MediaTracker(this);
carregador.addImage(imagem, 0);
carregador.waitForID(0);
return imagem;
catch(Exception erro)
erro.printStackTrace();
System.exit(0);
return null; -
Resize and crop images to a specific width and height
Hi,
I want to convert images to thumbnails with a 'standard' format - I need all images to have the same width and height.
So I need to resize and then crop the images. Is this possibe with JAI? Are there other libraries which can do this better?
I've read about ImageMagick - are the Java interfaces to ImageMagick good?
/best regards, Håkan Jacobsson - System developer in SwedenDuplicate posting, answers are here
http://forums.sun.com/thread.jspa?threadID=5419291
Pleas don't duplicate unless you note that you have done so and provide pointers to the duplicates - as I'm sure you're aware. . . -
Hi,
We are indexing file share with images and get the properties of Image Width, Image Height, Image Size (we show it as refiners in SharePoint after make it managed properties). Somehow when the picture is png format - we see only Size but not height and width.
Is that any setting that should be done in the file share (when i select an image in the windows explorer window i can see all its properties, and it seems that png files do expose the width and height properties
keren tsurHi Keren,
According to your description, my understanding is that when you tried to crawl file share with images, the ows_ImageWidth and ows_ImageHeight crawled property for PNG file could not be generated.
For your issue, I can reproduce your issue in my SharePoint 2013 environment. For a workaround, you can upload the PNG images into SharePoint images Library and they would work fine.
Best Regards,
Eric
Eric Tao
TechNet Community Support -
I cannot get DW8 to insert the width and height automatically
whern inserting an imge. Can anyone help me with it. TIAI have just discovered that if you do the insertion when Code
view and
Design view are 'in synch', i.e., neither the Property
inspector nor the CSS
panel have a "Refresh" button, the width and height will be
inserted in Code
view.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"intedeco" <[email protected]> wrote in
message
news:ebdb54$5uq$[email protected]..
> Thanks ACE for the info. I am using the technique you
mentioned.
> However, I
> did not have this problem in DWMX. Also, according to
Macromedia 'HELP'
> it is
> inderted automatically. Thios is what is says:
>
>
W and H are the width and height of the image, in pixels.
Dreamweaver
> automatically updates these text boxes with the image?s
original
> dimensions
> when you insert an image in a page.
>
> Hopefully, next update will fix this!
> -
Losing width and height information of Image???
Hi,
I am losing the width and height information between converting an image to byte[] and then back to Image
public void testImageToBufferAndBack(Image takenImage){
BufferedImage bufimage = this.ImageToBufferedImage(takenImage);
System.out.println("buffimage"+bufimage.getWidth()+" "+bufimage.getHeight(null)); //works fine
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
ImageIO.write(bufimage, "jpeg", stream);
catch (IOException ex) {
byte[] bytes = stream.toByteArray();
byte[] pictureBytes = bytes;
Image testImage = Toolkit.getDefaultToolkit().createImage(pictureBytes);;
System.out.println("tttttttteeeeeeeessssssttt "+testImage.getWidth(null)+" "+testImage.getHeight(null));
Output:
buffimage320 240
tttttttteeeeeeeessssssttt -1 -1
Could someone point me out my mistake please??Your mistake is not realizing that java.awt.Image loads images asynchronously. When Toolkit's
createImage method returns an Image, that image contains no pixel data -- as you've seen above, it doesn't
even know the size of the image! I knew this was the behaviour of the createImage method that took a URL,
but was surprised here that this is also the case with the version that takes a byte[], but undoubtably, that is
what is happening here. The way to fix this is always the same: use a MediaTracker, as my demo below
illustrates.
A couple points:
1. If you render your image in a custom component like this it will eventually appear:
g.drawImage(image, x, y, this); //for exampleThat's because Component's default behaviour as an ImageObserver (the reason for the final this)
is to continually repaint as more pixel data becomes available. This is not always the best solution -- what
if you need to know the image's dimension sooner rather than later?
2. ImageIcon can load an image for you, by using a MediaTracker behind the scenes:
Image image = ...
new ImageIcon(image);
//now image is loaded...Just be aware that if you use its constructors that don't take Image, but for example URLs
URL url = ...
Image image = new ImageIcon(url).getImage();Behind the scenes it's first getting the Image with Toolkit's getImage (not createImage). Toolkit's
getImage caches the image, which may not be what you want if you are processing many images --
why have the image loiter in memory if there is no advantage to that?
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import javax.imageio.*;
public class Example {
public static void main(String[] args) throws IOException {
String url = "http://today.java.net/jag/bio/JagHeadshot-small.jpg";
BufferedImage original = ImageIO.read(new URL(url));
displayDimensions("original buffered image", original);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(original, "jpeg", out);
byte[] bytes = out.toByteArray();
Image image = Toolkit.getDefaultToolkit().createImage(bytes);
displayDimensions("created image", image);
loadImage(image, new Label()); //any component will do
displayDimensions("loaded image", image);
System.exit(0);
//handy dandy utility method
public static void loadImage(Image image, Component comp) throws IOException {
MediaTracker mt = new MediaTracker(comp);
mt.addImage(image, 0);
try {
mt.waitForID(0);
} catch (InterruptedException e) {
throw new RuntimeException("Unexpected", e);
if (mt.isErrorID(0))
throw new IOException("Error during image loading");
static void displayDimensions(String msg, Image image) {
System.out.println(msg + ", w=" + image.getWidth(null) + ", h=" + image.getHeight(null));
}Output:
original buffered image, w=235, h=240
created image, w=-1, h=-1
loaded image, w=235, h=240 -
Current page (not Document) width and height with JSX
Hi,
I am trying to create a script that saves every page of the document and add its width and height to the name.
So far I managed to get the dimensions of the document using:
app.activeDocument.pages.documentPreferences.pageWidth;
app.activeDocument.pages.documentPreferences.pageHeight;
That's ok when all the pages in the document have the same dimensions (Document Preferences).
However, when I use custom pages that does not work.
I tried the code below but does not work either.
for(i=0; i<nb;i++)
app.activeDocument.pages[i].documentPreferences.pageWidth;
app.activeDocument.pages[i].documentPreferences.pageHeight;
I have done some research and I don't seem to find any information regarding custom pages dimensions.
Can you please help with this?
Thanks in advance,
IskoMain();
function Main() {
var doc = app.activeDocument,
pages = doc.pages,
page, width, height;
for (var i = 0; i < pages.length; i++) {
page = pages[i];
width = page.bounds[3] - page.bounds[1];
height = page.bounds[2] - page.bounds[0];
$.writeln("Page: " + page.name + " - " + "width = " + width + ", height = " + height); -
How can I get the image width and height stored in database?
Hi!I write s servlet to display images store in database.but how can I get the image width and height?
Have you tryed using PJA or a similar library?
I presume you get java.lang.NoClassDefFoundError on the line :
Toolkit.getDefaultToolkit();? -
How do you create aligned interactive text boxs in a PDF with the same width and height?
how do you create aligned interactive text boxs in a PDF with the same width and height?
Without free hand creating the sizing?Assuming by "interactive text boxes" you mean form fields; in Acrobat, make a form field, then copy it and paste. (GIve the pasted copy a different name so they don't genetate the same field feedback.) Now you have two fields of the exact same size. Shift-click or marquee-drag to select both, then right-click and choose a command from the Align, Distribute or Center menu.
-
How to calculate actual selection or group width and height with clipping
If a group has clipping paths then the height and visible bounds will include the dimensions of all paths selected including the clipped or hidden paths.
However, the width and height shown on the width and height of the AI detail boxes for the selection shows just the visible dimensions.
I want to retrieve the same values that is shown on the screen when a group is selected.
It is somewhat counterintuitive that the "visiblebounds" property does not show just what is visible.
I'm scaling the visible content of a selection to fit within another path but I need to be able to calculate the dimensions of the only what is visible after clipping.
What do you have to do with scripting to get these values? Go through all of the path items in a group recursively and save the min and max values of any visiblebounds for clipping paths? Any better alternatives that I don't see?
Thanks for any help!I ended up using the visible bounds for both scale and position as I also discovered that attempting to position a group with the position method would also result in missing the mark. The top and left (x,y) bounds I calculated without the clipped dimensions needed to be used to offset the actual position where I wanted the visible paths to be displayed.
The functions I used ended up looking like so:
function GetPoints(dblInch)
var dpi = 72;
return dblInch * dpi;
function getRealVisibleBounds(grp) {
var outerBounds = [];
for(var i = grp.pageItems.length - 1; i >= 0;i--) {
var bounds = [];
if(grp.pageItems[i].typename == 'GroupItem') {
bounds = getRealVisibleBounds(grp.pageItems[i]);
else if((grp.pageItems[i].typename == 'PathItem' || grp.pageItems[i].typename == 'CompoundPathItem')
&& (grp.pageItems[i].clipping || !grp.clipped)) {
bounds = grp.pageItems[i].visibleBounds;
if (bounds.length > 0) {
outerBounds = maxBounds(outerBounds,bounds);
return (outerBounds.length == 0) ? null : outerBounds;
function positionVisible(grp,x,y)
var bounds = getRealVisibleBounds(grp);
var newX = GetPoints(x) + (grp.left - bounds[0]);
var newY = GetPoints(y) + (grp.top - bounds[1]);
grp.position = [newX,newY];
function maxBounds(ary1,ary2) {
var res = [];
if(ary1.length == 0)
res = ary2;
else if(ary2.length == 0)
res = ary1;
else {
res[0] = Math.min(ary1[0],ary2[0]);
res[1] = Math.max(ary1[1],ary2[1]);
res[2] = Math.max(ary1[2],ary2[2]);
res[3] = Math.min(ary1[3],ary2[3]);
return res;
and were called like so:
var doc = app.activeDocument;
if (doc.selection.length > 0) {
var grpOriginal = null;
if(doc.selection.length == 1 && doc.selection[0].typename == 'GroupItem') {
grpOriginal = doc.selection[0];
else {
grpOriginal = doc.groupItems.add();
doc.selection = null;
if(grpOriginal.layer.name != 'approval') {
grpOriginal.move(doc.layers['approval'],ElementPlacement.PLACEATEND);
var artBounds = getRealVisibleBounds (grpOriginal);
var artWidth = artBounds[2] - artBounds[0];
var artHeight = artBounds[1] - artBounds[3];
var imprintHeight = GetPoints(0.625); // 0.625 is new height, hardcoded for demonstration
var imprintRatio = imprintHeight / artHeight;
var section = doc.layers['sectionLeft']; // section where I placed the art
var grpArt = grpOriginal.duplicate(section,ElementPlacement.PLACEATEND);
grpArt.resize(100.0 * imprintRatio,100.0 * imprintRatio);
grpArt.move(section,ElementPlacement.PLACEATBEGINNING);
grpArt.selected = true;
positionVisible(grpArt,0.0,16.75); // x & y hardcoded for demonstration
else {
alert('artwork needs to be selected');
I'm new at this so are there any better options to do these things? -
Get width and height of a dynamically loaded image once it's done loading?!
hello : :
well... i'm taking my first shots at flex after programming
in flash for a year now. it's been fun and i've been picking up on
things pretty well (or so i think), but i come across something
today that i used to be able to do in my as2 programming and don't
know how to do in as3...
in flex, i'm loading an image into an image control (by using
"myImgControl.load(urlString)"). i have a "complete" parameter on
the image control that calls a function just fine after the image
is loaded, but if i try and check the hight and width of the loaded
image once it loads, it comes back as zero. how can i get the
height and width of the image after it's loaded?!
in flash/as2 i used to do this little trick/work-around i
found in a forum (kirupa.com, i think) to find out the width and
height once the loaded image listener checked the loading process
and came back "complete"... in the code below, "imgLoader" is the
movieClip the image was loaded using
imgLoaderListener.loadClip(urlString, imgLoader).
quote:
iTot = imgLoader.getBytesTotal();
iLoad = imgLoader.getBytesLoaded();
if (iLoad == iTot && iTot > 4) {
imgH = imgLoader._height;
imgW = imgLoader._width;
that all make sense?!
basically, it's as simple as this: i need to find something
similar to the above for as3 that will tell me the width and height
of a dynamically loaded image after it's done loading...
so there ya have it. i appreciate any help any of you can
throw my way! thank you so much for even reading this!
: : michaelI assume you have probably already figured this out, but just
in case, there should be an event to listen for after which you can
get the height and width information successfully. I can't remember
the exact name, however. Experiment and see which one works
time-wise.
Maybe you are looking for
-
Make all the forms at a user level or responsibility level to be read only
Hi, Please suggest me to make all the forms at a user level or responsibility level to be read only. So that when a particular user logs in, he gets all the form in read only mode or at a particular responsibility all the forms are read only so that
-
Failure upon boot - cannot recognize root drive
Hello, I am new to Arch Linux. I 3want to build and boot 3.* kernel from Linus' git repository. It seems to build OK, but I cannot boot it successfuly. I stops at processing uevents and drops me to shell. I build it with makepkg -ci method . I suspec
-
Hi gurus, Can anyone clarify me these questions please 1) Difference between merge in 9i and merge in 10g 2) in a bulk insert, do we have any restriction about number of records.. in the sense, how many records can i insert into a table using bulk in
-
Maximum number of signatures?
Is there a maximum number of signatures allowed in Mail? I seem to only be able to access the first 255. Mail allows me to add more signatures but I can't access them from a mail message in the dropdown menu.
-
Heap dump file size vs heap size
Hi, I'd like to clarify my doubts. At the moment we're analyzing Sun JVM heap dumps from Solaris platform. Observation is that heap dump file is around 1,1GB while after loading to SAP Memory Analyzer it displays statistics: "Heap: 193,656,968" which