![]() Where mask.png has white pixels for what I want to keep of source-and-target.png and transparent pixels for what I want to remove (and become transparent) of source-and-target.png. Single command preferred multi-command chain acceptable.Įxtra info: Here's the composite command I'm using: gm composite -compose copyopacity mask.png source-and-target.png source-and-target.png rotate -90 rotates the whole image anti-clockwise 90. 288 is the number of pixels for a 72DPI (printing) resolution. resize 288 resize to a width of 288 pixels (4 inches) keeping the aspect ratio. My only missing piece is square-alizing non-square images (padding with transparency). convert inputfile.png -resize 288 -rotate -90 outputfile.png. I already know how to scale down and keep aspect ratio I already have the command for applying my composite. ULTIMATELY, what I want is to take any image of any GM-supported format of any size, and create a scaled-down PNG (say, 40 pixels maximum for either dimension), with aspect ratio maintained, transparency-padded for non-square original images, AND with an already-prepared 40x40 PNG transparency mask applied. ![]() Then I wrote a script as follows to compress the reference image using all the possible filters, strategies and levels to see the filesizes and if they have suffered any losses and are therefore different from the reference PPM image:Ĭonvert -depth 24 -size 200x200 xc:red gradient:black-white \( xc:white +noise random \) +append reference.pngĬonvert reference.png -define png:compression-filter=$f -define png:compression-level=$l -define png:compression-strategy=$s "$outfile"Įcho filter:$f, level:$l, strategy:$s, size:$sizeĪll files compared identically, so there doesn't seem to be any compression loss with any of the parameters I used.Alternatively: How do I take a non-square PNG and "fill out" the "rest" of the image with transparency so that the resulting square image has the original image centered in the square? This contains no date, or time or statistics or anything but pure image data and size in an extremely simple format - thereby allowing comparison of whether pixel values have changed through compression. In order to test whether you have lossless compression, I would suggest you convert images to PPM format - see here. It contains a readily compressible block of solid colour (red), a black-white gradient and a bunch of noise, so there is something to make most types of compression happy or unhappy in there. ![]() I don't have access to your images, so I generated a reference image myself, as follows. I think you are at, or beyond, the limits of the ImageMagick documentation and would like to suggest you work out your answer empirically - or if you do get a definitive answer, that you at least test it empirically. Any idea how to achieve better lossless compression?.Is this lossless compression? If not, where is the mistake?.It might be that compression-filter of 9 and compression-strategy of 0 are producing smaller size images, but I am still not sure if it is lossless or not). (If I use default compression strategy 0, I get large files. If you are using an old zlib that does not support Z_RLE (before 1.2.0) or Z_FIXED (before 1.2.2.2), values 3 and 4, respectively, will use the zlib default strategy instead." compression strategy is 2 huffman_only (so no filtering, although this compression filter shall be lossless)Īccording to the documentation: "valid values are 0 through 4, meaning default, filtered, huffman_only, rle, and fixed ZLIB compression strategy. magick -size 60圆0 xc:none -fill white -stroke black \ -draw 'circle 30,30 5,20' circle.png magick circle.png -crop 10x10+40+3 +repage -scale 600 circlemag.png As you can see the edge of the circle on the left drawn (in PNG format) as a very clean looking (though slightly fuzzy) edge to the image.define png:compression-level=9 -define png:compression-strategy=2 These are current arguments I'm playing with: convert -depth 24 -define png:compression-filter=1 \ ![]() I tried a few things, but it looks to me like the resulting PNG image is not as sharp as original image, although my wife cannot see it. I'd like to achieve a maximum amount of compression when saving to a lossless PNG using ImageMagick.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |