unexpected result of image flattening - doubling the width..

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: unexpected result of image flattening - doubling the width..

Post by fmw42 »

This works for me on my Godaddy server account

<?php
$IM_list=shell_exec("/usr/local/bin/convert -list");
echo $IM_list
?>

as do these


<?php
system("/usr/local/bin/convert -list");
?>

<?php
exec("/usr/local/bin/convert -list",$out,$returnval);
print_r($out);
?>
tobycarr

Re: unexpected result of image flattening - doubling the width..

Post by tobycarr »

Thanks - handy options.
As I said all other lists were working fine with my old verbose info method - it was only when there was no extra option between -list and -verbose that it didn't like it..
but I am sure the options you have offered are cleaner and more flexible for ALL ..ta
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: unexpected result of image flattening - doubling the width..

Post by anthony »

tobycarr wrote:Great! Thank you very much - works nicely. SO does that mean a png file created with IM carries some IM-based info like virtual canvas dimensions, or is that standard for pngs? Excuse my ignorance..
IM usually does not add IM specific information to an image. But in the case of PNG, it does.

PNG images by default can include a page offset. Im only adds the canvas size. when reading a PNG that does nto have a canvas size, it will try and figure out an appropriate canvas size so the image remain visible.

See IM Examples Common File Formats, PNG and the virtual canvas
http://www.imagemagick.org/Usage/formats/#png_offsets

You however reset any offset that was present in the image using -page before reading the image. But you can also reset it using -repage as well after reading.
for example...

Code: Select all

   convert   \( bg_image.png +repage \)  \( overlay.png -repage 0x0+25+25 \) ....
better still you should have used +repage before saving it originally!!!!! That is always a good idea when you don't want to preseve that information from the original -crop


Another alturnative is to have used -layers merge +repage instead of -flatten This ignores any existing canvas size information and generates the smallest image that contains all the image layers. However you again may have to remove that images offset and canvas information to finish up.

See Layers Merge
http://www.imagemagick.org/Usage/layers/#merge


Also using -composite instead would have ignored all layer information present (different technique and style of image handling) You would set an 0ffset using -geometry. However while it ignores all layer offsets and sizes, it does NOT clear that information if present either.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
tobycarr

Re: unexpected result of image flattening - doubling the width..

Post by tobycarr »

Very comprehensive and educational - thanks Anthony - will refine technique accordingly.
Post Reply