Cropping .mpc file using Filename Percent Escape

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
snake211

Cropping .mpc file using Filename Percent Escape

Post by snake211 »

Hi gurus,

I am cropping an image which is stored as .mpc format. Cropping it without x-, y- offsets creates tiles with auto-generated output filenames. To control the output filenames, I want to use the "Filename Percent Escape". I am using shell script and below is the code:

---------------------
$mpc_tmp="./tmp_$$.mpc"
$cache_tmp="./tmp_$$.cache"

convert "xxx.jpg" $mpc_tmp
# [above] storing xxx.jpg into a variable is inevitable because of other processes which are omitted here.
...
convert $mpc_tmp -crop 256x256 -set filename:tile "%[fx:page.x/256+1]_%[fx:page.y/256+1]" +repage +adjoin "tile_%[filename:tile].jpg"
---------------------

This does not work. It only generates the .jpg tiles with tiny sizes (about 300bytes). Also, this generates .cache files with the same names (tile_*_*.cache) as the .jpg files. These .cache files are huge (about 500 mbytes).

If I save $mpc_tmp into a dummy .jpg file, and then crop, it works:
---------------------
convert $mpc_tmp "tmp.jpg"
convert "tmp.jpg" -crop 256x256 -set filename:tile "%[fx:page.x/256+1]_%[fx:page.y/256+1]" +repage +adjoin "tile_%[filename:tile].jpg"
---------------------

Does anyone know why this is happening? I know that cropping without using the "Filename Percent Escape" works just fine on the .mpc files.

Thanks in advance.

J.R.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Cropping .mpc file using Filename Percent Escape

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.2-1 Beta. Thanks.
Post Reply