If I do as described below, I end up with an image of size 1572x1560 instead of the requested 1607x2100. Any idea why?
Regards, Marcel
input file:
http://dl.dropbox.com/u/219844/desktop.png
script:
convert desktop.png -crop 1607x898+35+108 part.png
convert part.png part.png part.png part.png part.png -append in.png
convert in.png -crop 1607x2100+0+0 out.png
identify out.png
output:
out.png PNG 1572x1560 1920x6000+35+540 8-bit DirectClass 2.115MB 0.000u 0:00.000
crop bug
Re: crop bug
After looking into this some more, I see weird things going on:
$ identify part.png
part.png PNG 1607x898 1920x1200+35+108 8-bit DirectClass 1.237MB 0.000u 0:00.000
$ identify in.png
in.png PNG 1607x4490 1920x6000+35+540 8-bit DirectClass 6.175MB 0.000u 0:00.000
The offsets in part.png (+35+108) are taken from my original crop. This becomes +35+540 in in.png. By the way, those are just the number of pixels that I am missing in out.png (35 horizontally and 540 vertically).
If I open all 3 created files in Acorn, and save them again, I get:
$ identify part.png
part.png PNG 1607x898 1607x898+0+0 8-bit DirectClass 1.596MB 0.000u 0:00.000
$ identify in.png
in.png PNG 1607x4490 1607x4490+0+0 8-bit DirectClass 7.968MB 0.000u 0:00.000
$ identify out.png
out.png PNG 1572x1560 1572x1560+0+0 8-bit DirectClass 2.727MB 0.000u 0:00.000
which looks a lot better. (And how the script works, with part.png as input)
What are crop and append doing to to the second dimension field??
$ identify part.png
part.png PNG 1607x898 1920x1200+35+108 8-bit DirectClass 1.237MB 0.000u 0:00.000
$ identify in.png
in.png PNG 1607x4490 1920x6000+35+540 8-bit DirectClass 6.175MB 0.000u 0:00.000
The offsets in part.png (+35+108) are taken from my original crop. This becomes +35+540 in in.png. By the way, those are just the number of pixels that I am missing in out.png (35 horizontally and 540 vertically).
If I open all 3 created files in Acorn, and save them again, I get:
$ identify part.png
part.png PNG 1607x898 1607x898+0+0 8-bit DirectClass 1.596MB 0.000u 0:00.000
$ identify in.png
in.png PNG 1607x4490 1607x4490+0+0 8-bit DirectClass 7.968MB 0.000u 0:00.000
$ identify out.png
out.png PNG 1572x1560 1572x1560+0+0 8-bit DirectClass 2.727MB 0.000u 0:00.000
which looks a lot better. (And how the script works, with part.png as input)
What are crop and append doing to to the second dimension field??
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: crop bug
PNG saves the virtual canvas offsets when you crop. If you do not want the offsets afterwards add +repage after the crop. See http://www.imagemagick.org/Usage/crop/#crop_repage
Re: crop bug
Thanks Fred, I should have read the documentation better.
I'm still puzzled though why append would add the offsets. How can that be useful? The sum of the offsets don't seem to refer to any real units.
I'm still puzzled though why append would add the offsets. How can that be useful? The sum of the offsets don't seem to refer to any real units.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: crop bug
I was talking about -crop. I am not sure how -append deals with the virtual canvas offsets as I don't usually keep them.
A quick test does indeed show that IM is adding the virtual offsets from appending two images.
A quick test does indeed show that IM is adding the virtual offsets from appending two images.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: crop bug
I do not believe append was looked at with regards to virtual offsets. My understanding was it does not use them.
I have no idea why it adds them together, though I can understand it adding virtual canvas sizes together. That may be part of it.
In any case how it deals with layer information is NOT defined in the Core library function (which is VERY simplistic!)
I would actually like to see append replaced with a more versatile 'layout' type operator, (see this proposal...)
http://www.imagemagick.org/Usage/ugs/future/#layout
I would hope such a future operator would also understand virtual offsets. But before that we should get 'justification' (as separate to gravity placement) working properly.
This would be something for IMv7 beta work.
I have no idea why it adds them together, though I can understand it adding virtual canvas sizes together. That may be part of it.
In any case how it deals with layer information is NOT defined in the Core library function (which is VERY simplistic!)
Code: Select all
% AppendImages() takes all images from the current image pointer to the end
% of the image list and appends them to each other top-to-bottom if the
% stack parameter is true, otherwise left-to-right.
%
% The current gravity setting now effects how the image is justified in the
% final image.
%
% The format of the AppendImages method is:
%
% Image *AppendImages(const Image *images,const MagickBooleanType stack,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o images: the image sequence.
%
% o stack: A value other than 0 stacks the images top-to-bottom.
%
% o exception: return any errors or warnings in this structure.
%
I would actually like to see append replaced with a more versatile 'layout' type operator, (see this proposal...)
http://www.imagemagick.org/Usage/ugs/future/#layout
I would hope such a future operator would also understand virtual offsets. But before that we should get 'justification' (as separate to gravity placement) working properly.
This would be something for IMv7 beta work.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/