I want to pixelate and/or blur an image.
I've found the command for the blurring:
$convert image.jpg -blur 18,5 newimage.jpg
to work but I cannot blur the image any more.
And how do I pixelate the image? I couldn't find a sound example around the net.
Thx
To get a proper square pixellation, try:
convert -scale 10% -scale 1000% original.jpg pixelated.jpg
This worked nicely for me, gives a sort of cross between pixelating and blurring:
convert -resize 10% image.jpg newimage.jpg
convert -resize 1000% newimage.jpg newimage.jpg
You can be sure that the data cannot be retrieved, should that be important to you.
Changing the %ages will change the amount of pixelation/blur
I don't know anything about ImageMagick, but you can try resizing the image using bicubic to a much smaller dimension, then resizing the image back to a bigger one.
The trick works using .net's System.Drawing object.
Related
im trying to resize image from 72x72 to 512x512 with following command
convert input.png -resize 512x512 output.png
but the output image (output.png) become blur
how to prevent resized images from becoming blurred
how to prevent resized images from becoming blurred
If you want a pixelated image of the original use -sample
# Create small image.
convert -size 72x72 plasma: 72x72.png
# Magnify the image with pixel subsampling.
convert 72x72.png -sample 512 512x512_sample.png
It's true that you can't restore missing data when upscaling images, but there's a lot of various algorithms to calculate what may be missing.
Try using the -filter option in addition to -resize, and checkout the wonderful usage examples here.
Probably the best you can do is use a sharper -filter such as catrom and then do post processing using -unsharp.
convert input.png -filter catrom -resize 512x512 -unsharp 0xSigma output.png
where sigma is the sharpening value, try sigma=1 or 2 (or as desired)
But it will not maintain the same quality as the input as others have mentioned above.
See -unsharp at http://www.imagemagick.org/script/command-line-options.php#unsharp
You can't. For an equal sharpness, you would need more data in the bigger image. Since you have only the data from a small image the result is blurred.
Look at it the other way, if what you asked was possible, instead of compressing the 512x512 image, we would first scale it down to 72x72, compress that (much smaller file) and sent it over with instructions to scale it up to 512x512.
I've read the ImageMagick documentation here and here and been unable to achieve a couple of simple tasks. Would appreciate any simple pointers or direction, or even commands I can execute that will work on Linux.
I want to convert any image-type (JPG, GIF, PNG, TIFF) to save to a PNG, losslessly, and as compressed as possible without any loss of quality. Ideally in 96 DPI so they look good in Retina screens.
To then take the above generated PNG and also resize it in specific sizes, with height and width specified.
What am I missing with the convert command?
If you want to convert a TIF, GIF or JPEG to PNG, the command is:
convert image.tif result.png
or
convert image.jpg result.png
In answer to your questions...
Question 1
PNG is lossless by definition, so that is not an issue. To get better compression of a PNG, you generally need to reduce the colours, i.e.
convert image.jpg -colors 64 result.png # or try 255 which allows a palettised image
The dpi is pretty irrelevant until you print on paper. More pixels are needed if you want more quality on screen.
Question 2
If you want to resize an image without destroying its aspect ratio, use
convert image.jpg -resize 200x100 result.png # retain aspect ratio
If you don't care if that makes the image look stretched or distorted, and you want exactly 200x100, tell ImageMagick that you really mean it by shouting:
convert image.jpg -resize 200x100! result.png # ignore aspect ratio
I need to resize image based on memory.
What I am getting is following option in "convert" command.
-resize 800x600
-resize 25%
Is there any command like -
-resize 10KB
Thanks
Use this:
convert input.jpg -define jpeg:extent=300kb ... output.jpg
If you want a way to do something similar with Python, I wrote an answer that works pretty well here. It does a binary search for a JPEG quality that satisfies a maximum size requirement.
I am using convert from PDF to PNG.
$ convert -density 203.294113 -resize 6000x3300\> src.pdf[0] dst.png
But when the image is created, it has a white margin added around the origin pdf page and I don't know how to eliminate it (it doesn't matter whether "density" and "resize" are used). Thanks a lot for the help.
you can use -shave to remove border with specific size or -trim to auto-trim image
I have an SVG with many polygons:
https://github.com/barrycarter/bcapps/blob/master/sample-data/current-temps.svg
that looks somewhat like this:
Cropping this and converting to PNG works fine:
convert -crop 100x100+200+150 current-temps.svg /tmp/exhb2.png
Cropping and scaling, however, fails:
convert -crop 100x100+200+150 -scale 1000x750 current-temps.svg /tmp/exhb3.png
How do I make ImageMagick "zoom into" the SVG before cropping?
(I realize ImageMagick can only read, not write, the SVG format, but
it should still be able to do what I want?)
EDIT/SOLVED:
Thanks, robermorales.
inkscape -z -e out4.png -w 1000 -h 1000 -a 200:200:400:400 current-temps.svg
(for example) worked like a charm.
I also realized that copying the SVG, tweaking the transform line:
<g transform="scale(3,3) rotate(-90) translate(-90,180)">
and then converting to PNG is another solution.
Try doing scale before crop.
However, doing that using inkscape cli is easier.
Sorry for no links, afk
Don't crop an SVG into PNG.
You can use viewBox to re-define the crop area then convert that SVG into PNG in highest solution as possible.
Check this post https://www.sarasoueidan.com/blog/svg-coordinate-systems/ explain what is viewBox and you will got my idea.
Proper ImageMagick syntax here is to read the input, then crop, then resize. See http://www.imagemagick.org/Usage/basics/#why Though that is not likely the issue. The issue is that -scale will replicated pixels and so make it blocky. You should replace -scale with -resize. That will be smoother, but blurry for the amount of magnification you are requesting. Try this command:
convert current-temps.svg -crop 100x100+200+150 -resize 1000x750 exhb3.png