LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (http://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   Producing a good quality png/jpg/gif etc from inkscape (http://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/producing-a-good-quality-png-jpg-gif-etc-from-inkscape-900623/)

chadwick 09-01-2011 07:46 PM

Producing a good quality png/jpg/gif etc from inkscape
 
Producing a decent quality png from inkscape wasn't obvious to me. By the time I need to do such a thing again, I'll probably have forgotten what I did, so I'm recording here the steps involved. People who are well-versed in image manipulations will probably know other ways, but here's what worked for me.

1) From inkscape, save your file as an eps. File->Save a Copy and then choose Encapsulated Postcript (*.eps) in the dropdown for the file type. I chose Postscript Level 3 (although I don't know what the significance of that is) and resolution for rasterization of 500 dpi. It may be good to play around with this dpi resolution if that's worthwhile in your case.

2) Now we can use pstoimg to convert the ps file to a bitmapped image. In Debian, pstoimg is available in the package latex2html. The good thing about the eps file type is that it makes it easier for pstoimg to know what the appropriate boundaries of the image are. We can crop around the edges using the option "-crop a". The "-density" option allows us to control the quality of the output (as in dots per inch density).

Suppose you saved this eps file to mydir/myfile.eps
Then change to the directory mydir/ and issue a command like:

$pstoimg -crop a -density 500 myfile.eps

This by default converts to png with output myfile.png although if you look through the options it seems it allows you to produce other formats as well. But if you want another format, you can wait till step 3 anyway.

3) The result of step 2 can take up a large pixel x pixel area. Now we resize it to how many pixels we want using convert. In my case I want it 1000 pixels wide so I do:

$convert myfile.png -resize 1000 myfile.png

Note that convert can also convert to jpg or gif among other image types so say for example if you want jpg format then in this last step you can output to myfile.jpg instead:

$convert myfile.png -resize 1000 myfile.jpg


All times are GMT -5. The time now is 08:59 AM.