: How can I pixelate an image via the command line on Linux Is there a command-line utility for Linux that can pixelate an image by a specified percentage eg "-pixelate 30%"
Is there a command-line utility for Linux that can pixelate an image by a specified percentage eg "-pixelate 30%"
More posts by @Lee3735518
3 Comments
Sorted by latest first Latest Oldest Best
If you have ruby installed this might be a possible option for you.
See this gist gist.github.com/71598aeb1d823c9229ac
It uses chunky_png to pixellate the image, so you may need to adapt the code slightly if you want to produce other file formats.
For more information about it see this link codebrawl.com/contests/pixelizing-images-with-chunkypng
Not sure how comfortable you with adapting code, but I could try to convert it into a simple command line application if you think it would be worthwhile.
I think the usual trick is to scale down so that you lose resolution and then scale up to magnify the low-res image. So with Imagemagick, something like this:
convert -scale 10% -scale 1000% original.jpg pixelated.jpg
UPDATE: if you just want to be able to specify a single "pixelation amount" value, then the above command can be wrapped in a shell script as follows
#!/bin/bash
MAGICK=/usr/local/bin/convert
AMOUNT=$(echo "1.001 - " | bc -l)
INFILE=
OUFILE=
COEFF1=$(echo "100 * $AMOUNT" | bc -l)
COEFF2=$(echo "100 / $AMOUNT" | bc -l)
$MAGICK -scale $COEFF1% -scale $COEFF2% $INFILE $OUFILE
If you then save the above script as pixelate.sh and make it executable with chmod 755 pixelate.sh, you can run it by specifying a pixelation amount between 0-1, an input file and an output file. For example:
./pixelate.sh 0.5 original.jpg pixelated.jpg
So, if you know how to do this with the Gimp via the point-and-click interface then you can probably write batch-mode script to do the same thing on the command line:
www.gimp.org/tutorials/Basic_Batch/
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.