Coordinate not correct when using crop and extent together

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
sangdaono
Posts: 3
Joined: 2015-11-16T18:23:19-07:00
Authentication code: 1151

Coordinate not correct when using crop and extent together

Post by sangdaono »

Here the command i used to splice an image into multiple:

Code: Select all

convert "input.jpg" -resize 1135x -crop 256x256 -background transparent -extent 256x256 -set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" +repage +adjoin "output\%[filename:tile].png"
Here the result:
Image
The last piece of the column was wrong y coordinate. it's return 9.25391 instead of 3. It should be 0_3.png. If i remove "extent 256x256", it's return correctly but some image not fit with size 256x256. I need all image have to be 256x256, if it not, extend the image and add transparent background it as the command above.
Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Coordinate not correct when using crop and extent together

Post by fmw42 »

Try putting the -set filename... before the -extent:

Code: Select all

convert "input.jpg" -resize 1135x -crop 256x256 -set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" -background transparent -extent 256x256 +repage +adjoin "output%[filename:tile].png"
This seems to work fine for me on IM 6.9.2.6 Q16 Mac OSX. Note on Unix it works better without the \ before %.

Please always provide your IM version and platform.
sangdaono
Posts: 3
Joined: 2015-11-16T18:23:19-07:00
Authentication code: 1151

Re: Coordinate not correct when using crop and extent together

Post by sangdaono »

Thank you so much. It's worked like charm!
I'm using IM 6.9.2-1 Q16 Win64
Post Reply