not sure if this is related to the GIF *resize* bug that is mentioned just recently here, but i have the latest build (6.4.8-9) of imagemagick, and i am seeing problems when i use "crop" on a gif. namely, the visible part of the image is the correct size, but the image itself (page size, i guess) is the original source image size.
i have created a page giving an example of the problem i am seeing.
thanks much for any feedback/help!
-jon
GIF crop problem
Re: GIF crop problem
Try the +repage option. http://www.imagemagick.org/script/comma ... php#repageMumonkan wrote:not sure if this is related to the GIF *resize* bug that is mentioned just recently here, but i have the latest build (6.4.8-9) of imagemagick, and i am seeing problems when i use "crop" on a gif. namely, the visible part of the image is the correct size, but the image itself (page size, i guess) is the original source image size.
i have created a page giving an example of the problem i am seeing.
thanks much for any feedback/help!
-jon
Re: GIF crop problem
wow, hm... that seems to solve the problem.
now i just need to figure out how to bubble this up into drupal code, where it is being called from. i guess it could get scary from this point out... haha
thanks!!
-jon
now i just need to figure out how to bubble this up into drupal code, where it is being called from. i guess it could get scary from this point out... haha
thanks!!
-jon
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: GIF crop problem
Cropping GIF animations are triky as it is NOT a single image
+repage is probably not a good solution.
See IM Examples, GIF Animation Modification.
http://www.imagemagick.org/Usage/anim_mods/
the first few examples has general GIF animation handling techniques methods and includes cropping. Later example goes into more difficult and complex problems.
+repage is probably not a good solution.
See IM Examples, GIF Animation Modification.
http://www.imagemagick.org/Usage/anim_mods/
the first few examples has general GIF animation handling techniques methods and includes cropping. Later example goes into more difficult and complex problems.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: GIF crop problem
I guess I'm confused. The way I read the OP's question, GIF animations are not involved, just a single-frame GIF. What did I overlook?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: GIF crop problem
I may have read more into 'GIF' than I should have.
Applogies.
Applogies.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: GIF crop problem
I had a similar issue cropping gifs that left the canvas the original size using the Magick++ API in C++, code looks like this:
Code: Select all
bool CropImage(char cFileIn[], char cFileOut[], int nNewWidth, int nNewHeight )
{
bool bRet = false;
char cLog[MAX_STRING_LARGE];
int nWidth;
int nHeight;
try
{
cLog[0] = NULL;
Image img_Cropped;
img_Cropped.read(cFileIn);
//Get width and height of original image
nWidth = (int)img_Cropped.columns();
nHeight = (int)img_Cropped.rows();
while (1)
{
if( (nNewWidth > nWidth) || (nNewHeight > nHeight)) //IF the cropped section overruns the image height or width
break;
img_Cropped.crop(Geometry(nNewWidth, nNewHeight, 0, 0 ));
img_Cropped.page(Geometry(nNewWidth, nNewHeight, 0, 0 ));
// save
img_Cropped.write(cFileOut);
bRet = true;
break;
}
}
catch(Exception &error_ )
{
sprintf_s( cLog, MAX_STRING_LARGE, "Caught Exception: %s", error_.what() );
}
return bRet;
}
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: GIF crop problem
That is standard!!!! -crop preserves the original virtual canvas
Remove it with +repage
http://www.imagemagick.org/Usage/crop/#crop
NOTE: In IMv7 the -crop operator may do this automatically with a +crop varient preserving the original canvas. It is on my ToDo list! It will not change in IMv6
Remove it with +repage
http://www.imagemagick.org/Usage/crop/#crop
NOTE: In IMv7 the -crop operator may do this automatically with a +crop varient preserving the original canvas. It is on my ToDo list! It will not change in IMv6
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/