2

I have a lot of various sized rectangular images. I would like to keep them centered, do not change their size and only add white space, so every image would be square. After that, I want to convert that square to PNG. I tried few commands in ImageMagick, but couldn't get expected result.

That command gives me almost expected result, however, SVG gets blurry:

magick mogrify *.svg -resize '128x128'-gravity center -extent '128x128' *.svg

What I want to do:

  1. Resize SVG to square SVG

  2. Do some work with SVG

  3. Then export it to 128x128 PNG

  • 3
    You're rasterizing an SVG to 128x128 pixels so getting 'blurry' isn't totally unexpected. Is there any reason you need to rasterize them at all? – Cai Dec 15 '17 at 15:34
  • You right. I completely lost my mind. What I want to do: 1) first: resize SVG to square SVG 2) second: do some work with SVG and then convert to 128x128 – curious Dec 15 '17 at 15:36
  • @Cai I meant I want to export it to 128x128 PNG, description corrected – curious Dec 15 '17 at 15:45
  • 1
    By resizing your SVG automatically you'll lose control of how the vector paths and points align to the pixel grid, so it will probably be blurry. Unless it's scaled down with perfectly round values. – Luciano Dec 15 '17 at 15:59
  • I think you should rethink your process: since you don't specify what "do some work with SVG" means, I cannot be sure but I would proceede as follow: 1) "do some work" with the SVG you already have 2) export the SVG through inkscape cli 3) use imagemagick to center and whitespace the resulting PNGs – Mattia Galati Feb 5 '18 at 14:46
0

If I understand this correctly I would go with trying to do this on actions in PS, first create your 128x128px file, start recording and then, select all, align it to center, flatten image, save as PNG. You could also add a create layer before the paste, to have a clear layer every time.

Example.

In this example action I pasted an image that I had on clipboard before everything so if you copy your image and run the action it will be saved. You may want to add a stop at "Save" action to rename your PNG. Then at the end I "Deselect" for safety, you could also "Delete or Fill with Color (alt+Delete)" then "Deselect" to clear the file before doing the next image. Also I had two layers and did this on a clear top layer, other one was the background (white).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.