ImageMagick crop with row / column name in the file name saves only the last image

I am trying to crop an image using ImageMagick and through PowerShell. I can crop the image with the following command, and it creates 2000+ images:

convert -crop 16x16 .\original.png tileOut%d.png

However, I would like to use the ImageMagick feature to dynamically set the file name.

According to the publication on my forums, I can start using a batch file something like the following:

convert ^
   bigimage.jpg ^
  -crop 256x256 ^
  -set filename:tile "%%[fx:page.x/256+1]_%%[fx:page.y/256+1]" ^
  +repage +adjoin ^
  tiled_%%[filename:tile].gif

I do not need to hide %, since I run it directly in PowerShell, so I used the following:

convert -crop 16x16 .\original.png -set filename:tile "%[fx:page.x/16+1]_%[fx:page.y/16+1]" +repage +adjoin directory\tiled_%[filename:tile].png

However, when I run this command, I get one file named tiled _% [file_name , and the other - tiled_45_47.png .

, , . 0 , 8 , .

, , PowerShell , .

+ adjoin , . + repage , , , , t, , . - .

, . , , :, PowerShell. . .

?

!

EDIT:

  • PowerShell 5.0.10586.0, Windows 10.
  • ImageMagick 6.9.2 Q16 (64- )

, ImageMagick.

+4
2

Powershell, , , , , :

convert original.png -crop 16x16 -set filename:tile "%[fx:page.x/16+1]_%[fx:page.y/16+1]" +repage "tiled_%[filename:tile].png"
+3

, % d , .

convert -crop 16x16 .\original.png directory\tileOut%d.png

. , , , convert. , , .

convert .\original.png -crop '16x16' -set 'filename:tile' '%[fx:page.x/16+1]_%[fx:page.y/16+1]' +repage +adjoin 'directory\tiled_%[filename:tile].png'

, .

+1

Source: https://habr.com/ru/post/1621792/


All Articles