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
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 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 a .eps file that I can look at in Photoshop, and it has a very high resolution, sharp edges, etc. at even larger than 1024x1024.
With ImageMagick I want to convert this .eps to a 1024x1024 .jpg with very high resolution.
However, with the following command, the image is very blurry:
convert -resize "1024x1024" -colorspace RGB -flatten test.eps test.jpg
What ImageMagick parameters do I have to use so that the resulting .jpg is 1024x1024 and a high quality, sharp image?
here's some XMP data we found, perhaps what is causing it to not be resized with -size:
For vector graphics, ImageMagick has both a render resolution and an output size that are independent of each other.
Try something like
convert -density 300 image.eps -resize 1024x1024 image.jpg
Which will render your eps at 300dpi. If 300 * width > 1024, then it will be sharp. If you render it too high though, you waste a lot of memory drawing a really high-res graphic only to down sample it again. I don't currently know of a good way to render it at the "right" resolution in one IM command.
The order of the arguments matters! The -density X argument needs to go before image.eps because you want to affect the resolution that the input file is rendered at.
This is not super obvious in the manpage for convert, but is hinted at:
SYNOPSIS
convert [input-option] input-file [output-option] output-file
Maybe you should try it with -quality 100 -size "1024x1024", because resize often gives results that are ugly to view.
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.