Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to resize an image (say png format) using convert. The tricky thing is that I want to retain the quality of the image when I resize the image back to the original dimensions.

For example,

convert -resize 50% original.png smaller.png
convert -resize 200% smaller.png backtooriginal.png

backtooriginal.png has a decreased quality compared to original.png, and I would like to avoid that. If it was one image, I can use tools like gimp. But I need to automate this.

Thanks!

share|improve this question

migrated from stackoverflow.com Nov 9 '12 at 23:48

This question came from our site for professional and enthusiast programmers.

1  
An intrinsic property of reducing the size is losing information. you cannot get it back again. –  Keith Nov 10 '12 at 0:06
    
Why not keep the original file around? No need to resize it back and no quality lost. –  Hennes Nov 10 '12 at 0:55
    
Hennes: I want a smaller size (dimension) for an image file. But when I reduce the size using resize, I lose resolution and the image does not look good. I was wondering how I could avoid that so I posed the resize 50%-resize back 200% question. –  Excalibur Nov 10 '12 at 1:24
add comment

1 Answer

up vote 1 down vote accepted

"If it was one image, I can use tools like gimp" - How can you do this even in GIMP? If you resize to 50% of the original dimension, you've discarded data. Blowing/scaling the raster image back up to the original size only duplicates pixels, it doesn't magically bring lost data back. PNG being a lossless format is not going to help in this case.

The only possible way you can do this AFAIK is to use a vector image format that ImageMagick supports, such as MVG or SVG.

Note: You can always try converting the raster images to vector first before resizing, but I doubt the results will be all that satisfactory.

share|improve this answer
    
Thanks Karan for your reply. You are correct that its not simple even in GIMP. I can go a round about way to accomplish this: I set print size to half which automatically doubles the resolution, and then print it to a pdf. Getting the image from the pdf is again not straightforward but it is possible. An easier solution which is generally what I do is to import the image in inkscape, scale it and export the image. This is along the lines of your comment that it has to be converted to svg to be able to scale it. Anyway, I am surprised that there is no tool that resizes but does not lose data. –  Excalibur Nov 10 '12 at 1:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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