Traditional crop/delete other pixels, rather than hiding pix

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?".
Post Reply
cjmi
Posts: 11
Joined: 2012-06-28T20:31:04-07:00
Authentication code: 13

Traditional crop/delete other pixels, rather than hiding pix

Post by cjmi »

So, I upgraded from ImageMagick 6.2.8/libtiff 3.8.2 to ImageMagick 6.7.8-0/libtiff 4.0.2.

On my old version, "convert someTiff.tif -crop 60x60+123+231 someTiffCropped.tif" did a traditional crop, which cut out a 60x60 pixel area from a large someTiff.tif file, at the 123, 231 coordinate.

On my new version, the same command crops to a 60x60 pixel area along the lines of the new Photoshop crop, where the other pixels are hidden in out of areas in the image. Results in a huge file.

Additionally, if I load this new version's cropped file in Photoshop CS6, it's showing me the 60x60 pixel area at the 0,0 coordinate -- not the 123, 231 coordinate. Either a bug in IM, libtiff, or PSCS6. Anyways, it doesn't matter to me in the end. :)

How can I tell ImageMagick/Magick++ to do a more traditional crop and delete the other pixels, rather than non-destructively hiding them? That should fix all my issues...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Traditional crop/delete other pixels, rather than hiding

Post by fmw42 »

You probably need to add the command line equivalent of +repage to remove the virtual canvas. Which is probably -repage +0+0. You will need to find the API equivalent as I don't code in any API.

see
http://www.imagemagick.org/Usage/crop/#crop_repage
cjmi
Posts: 11
Joined: 2012-06-28T20:31:04-07:00
Authentication code: 13

Re: Traditional crop/delete other pixels, rather than hiding

Post by cjmi »

You rock. (You have ninja fast responses.)

Truth is I'm using Magick++ in c++, just was using convert to test why things were going wrong.

Tried adding "-repage 0+0" to convert options, didn't change anything.

For in c++, I searched for the phrase "repage" in /usr/local/include/ImageMagick, and in ~/sourceInstallations/ImageMagick-6.7.8-0/Magick++/lib, and found nothing.
cjmi
Posts: 11
Joined: 2012-06-28T20:31:04-07:00
Authentication code: 13

Re: Traditional crop/delete other pixels, rather than hiding

Post by cjmi »

There's another way to go about it. Is there a way to create an Image, from a given area in a different Image? That (should) avoid the hidden pixel problem I'm in now.

... Right now I'm doing:

Code: Select all

Image croppedImage = uncroppedImage;
croppedImage.crop(Geometry(60, 60, startX, startY));
... Which is sort of wasteful, but I'm not worried about program execution time.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Traditional crop/delete other pixels, rather than hiding

Post by fmw42 »

cjmi wrote:You rock. (You have ninja fast responses.)

Truth is I'm using Magick++ in c++, just was using convert to test why things were going wrong.

Tried adding "-repage 0+0" to convert options, didn't change anything.

For in c++, I searched for the phrase "repage" in /usr/local/include/ImageMagick, and in ~/sourceInstallations/ImageMagick-6.7.8-0/Magick++/lib, and found nothing.
In command line your would add +repage just before the output.

Try looking for page or repage.

In command line you can specify the region of the image you want

convert image[WxH+X+Y] output

but I don't know anything about Magick++ or C++. Sorry.

Also look in your crop command to see if there are argunents for page or repage
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Traditional crop/delete other pixels, rather than hiding

Post by anthony »

The read modifiers will work from other API's.
But I do not know if they do a automatic +repage. Probably not.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply