I need to take a single PNG file, tile it 3x3 and then save it out, preserving the alpha channel.
I have worked my way to the following command:
montage original_file*.png -tile 3x3 -alpha set -geometry +0+0 tiled_file.png
montage sucks because it requires I have 9 identical files in the working directory, so my script generates them and then deletes them after the montage command. I tried to use the convert command in place of montage, which does not require multiple files to tile, but it was not handling the alpha channel properly. (convert -size {$newXresolution}x{$newYresolution} tile:original_file.png tiled_file.png) where the new resolutions are 3X the originals.
This montage command creates what I need, but when I compare the original file to the output file, the alpha channel starts off as 8-bit, but the output file shows it as 1-bit.
Is there a way to tell montage to keep all image parameters the same as the original file... especially the alpha channel settings? I tried saving using the PNG8:, PNG16, etc but this did not help.
Version of IM I am using: Version: ImageMagick 6.9.10-11 Q16 x86_64 2018-09-08
Any help is appreciated,
Chris
Austin, TX
PNG file manipulation
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PNG file manipulation
Why use montage. Just use append. Here is an example
# make transparent image from internal Imagemagick logo:
# make 3x3 tiling
# make transparent image from internal Imagemagick logo:
Code: Select all
convert logo: -transparent white logot.png
Code: Select all
convert logot.png -duplicate 2 +append \
\( -clone 0 -clone 0 \) -append \
result.png
Re: PNG file manipulation
Thank you fmw42. This works great. I now need to learn how duplicate, append and clone work so I can understand what this is actually doing
What if I wanted to add X number of pixels between each image... to space them out?
Chris
What if I wanted to add X number of pixels between each image... to space them out?
Chris
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PNG file manipulation
Or just one file and "-duplicate 8".cejones wrote:montage sucks because it requires I have 9 identical files in the working directory, ...
I suggest you remove "-alpha set" (which is harmless but pointless) and insert "-background None".cejones wrote:This montage command creates what I need, but when I compare the original file to the output file, the alpha channel starts off as 8-bit, but the output file shows it as 1-bit.
snibgo's IM pages: im.snibgo.com
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: PNG file manipulation
The other solutions offered above are good. Here's another pretty simple idea to make a 3x3 tiled result from a single input image...
Code: Select all
convert input.png -background none -duplicate 2 +append -duplicate 2 -append result.png
Re: PNG file manipulation
Thank you GeeMack. Yours is a cleaner looking line of code. I tested it and it works well.
And thank you snibgo. I modified my montage code with -duplicate 8 and it indeed removes the need for multiple files. Awesome day... learned how to use duplicate, append and clone.
Thank you all for the help!
And thank you snibgo. I modified my montage code with -duplicate 8 and it indeed removes the need for multiple files. Awesome day... learned how to use duplicate, append and clone.
Thank you all for the help!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PNG file manipulation
With GeeMack's "convert" command, you can "-border" immediately after the input.png, or "-extent" or "-splice", perhaps with a final "-chop", depending on the exact effect you want.cejones wrote:What if I wanted to add X number of pixels between each image... to space them out?
snibgo's IM pages: im.snibgo.com
Re: PNG file manipulation
-border works great and solves that question. Thank you snibgo. I really like your IM pages... lots of great scripts for me to learn from.