Get('geometry')

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Get('geometry')

Post by rmabry »

What's the right way to get all the image geometry, including page info?

I tried

$geom = $image->Get('geometry');

but this returns zilch (I'm still with 6.3.1-4). Using

($w,$h) = $image->Get('width', 'height');

and

($c,$r) = $image->Get('columns', 'rows');

both return identical (synonymous?) results, but I was hoping 'geometry' would give me the works: (width)x(height)+page.x+page.y.

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Use $image->Get('columns') to return the image width, Get('rows') for the image height, and Get('page') to get the page geometry (page width, height, x, and y). The page width/height may be different from the image width/height because it represents the image virtual canvas.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: Use $image->Get('columns') to return the image width, Get('rows') for the image height, and Get('page') to get the page geometry (page width, height, x, and y). The page width/height may be different from the image width/height because it represents the image virtual canvas.


Thanks, yes, 'page' is exactly what I thought 'geometry' would give. (What DOES 'geometry' return?)
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: Get('page') to get the page geometry (page width, height, x, and y).


Without resorting to split-ing or other perly string manipulations (which wouldn't be difficult, I'll grant), are the x and y ready to Get separately? E.g.,

$image->Get('pagex', 'pagey') ?

How's this?

Code: Select all

          if (LocaleCompare(attribute,"pagex") == 0)
            {
              if (image != (Image *) NULL)
                s=newSViv((long) image->page.x);
              PUSHs(s ? sv_2mortal(s) : &sv_undef);
              continue;
            }
          if (LocaleCompare(attribute,"pagey") == 0)
            {
              if (image != (Image *) NULL)
                s=newSViv((long) image->page.y);
              PUSHs(s ? sv_2mortal(s) : &sv_undef);
              continue;
            }
It seems to work for me and 'twould be useful.

"Can we keep it, Dad, please, can we keep it?"

(Used to work when we were kids.)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

We will instead use page.x and page.y as attributes available in the next Beta release by tommorrow.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: We will instead use page.x and page.y as attributes available in the next Beta release by tommorrow.


You are a indeed kind and speedy Santawizard.

Image
Post Reply