Re: Images and PDF:API2
"spinningwebz2002" <spinningwebz2002-/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.pdfapi2 |
|---|---|
| Message-ID | <[email protected]> |
--- In [email protected], "Mr. Shawn H. Corey" <shawnhcorey@...> wrote: > > spinningwebz2002 wrote: > > Thanks for the tip. Do you know how the scale option works? Or maybe > > if I tell you want I want to happen you can give me some pointers > > > > I want center an image and have the height be a particular size and > > the width be proportional to that. If it is possible I would like to > > crop the extra width if any, but I an always draw a white box over > > the extra width if need be. > > To calculate the scaling factor, you need to know how many pixels wide (or high) your image is and how wide, in points, you want the result. > > Example 1: a 4x6 photo at 300 dpi. > > $image_width = 4 * 300; # 4 inches at 300 dpi > $result_width = 4 * 72; # 4 inches at 72 points per inch > $scale = $image_width / $result_width; > > Example 2: a PNG of 1280 pixels wide to be shown sideways at 10 inches wide. > > $image_width = 1280; > $result_width = 10 * 72; # 10 inches at 72 points per inch > $scale = $image_width / $result_width; > > Example 3: a 3x2 inch photo at 150dpi to be shown at twice its size > > $image_width = 3 * 150; # 3 inches at 150 dpi > $result_width = 6 * 72; # 6 inches at 72 points per inch > $scale = $image_width / $result_width; > > > -- > Just my 0.00000002 million dollars worth, > Shawn > > "For the things we have to learn before we can do them, we learn by doing them." > Aristotle > If I know the image hieght but not the width (i am resizing it using Imagemagick), how would I get it to show the image correctly? Bill H