using inkscape to convert svg to jpeg - from a plugin
Hi,
If you might have noticed, I posted a message about the plugin/extension I wrote to upload images to Flickr/Picasaweb.
An important part of this plugin is to convert SVG to JPEG, because both of the above services don't accept SVG images. So the solution I am using in the current version of plugin is, using ImageMagick's "convert" command to do the above image format transformation. This is not an elegant approach, in my opinion. I can't get it to work on windows, etc.
I know Inkscape can let you save an SVG image as jpeg. But don't know how to do this programmatically. My extension works as an "output" extension, so it is triggered by the filename extension (.web). This mechanism pretty much isolates the extension developer from having programmatic interface with inkscape functionality. So I am not sure how I can access inkscape's svg-2-jpeg functionality, if at all there is an API exposing it.
It is also a possibility to fork another inkscape instance as command line and use --export-png to convert to PNG (I think flickr/picasa will accept png). But the conversion result was very poor when I tried it. When the SVG image contained some simple black lines on a white background, the resultant PNG contained only black lines and no background.
Any suggestions around these ideas will help.
Thanks in advance.
Cheers! Jayesh
On Fri, 28 Dec 2007 00:53:03 -0800 "Jayesh Salvi" <jayeshsalvi@...155...> wrote:
It is also a possibility to fork another inkscape instance as command line and use --export-png --export-pngto convert to PNG (I think flickr/picasa will accept png). But the conversion result was verypoor when I tried it. When the SVG image contained some simple black lines on a white background, the resultant PNG contained only black lines and no background.
In my experince, the --export-png produces excellent results. Your PNG didn't have a background because your SVG image didn't have one! Just draw a filled background rectangle and there's your background. In fact I always use such rectangles not only as a background but also as export-id objects.
--D.
Jayesh Salvi wrote:
An important part of this plugin is to convert SVG to JPEG, because both of the above services don't accept SVG images. So the solution I am using in the current version of plugin is, using ImageMagick's "convert" command to do the above image format transformation. This is not an elegant approach, in my opinion. I can't get it to work on windows, etc.
Look into using the gdk-pixbuf, it will enable other (sometime) requested formats in addition to JPEG, like GIF or TIFF.
See the relevant RFE for more comments: https://bugs.launchpad.net/inkscape/+bug/171390
If you are going to implement JPEG export, I think *a must* is an option to control the quality settings, preferably with visual feed-back. I had to manually convert such PNGs to JPEG and from my experience, a lot of fine tunning is needed for a good result.
Jayesh Salvi wrote:
It is also a possibility to fork another inkscape instance as command line and use --export-png to convert to PNG (I think flickr/picasa will accept png). But the conversion result was very poor when I tried it. When the SVG image contained some simple black lines on a white background, the resultant PNG contained only black lines and no background.
flickr will automatically convert at upload time the PNG to JPEG with a very poor result: you can't adjust the quality but, even worse, this will destroy the alpha transparency (blur shadows, antialiased edges), so this is not a viable option. Picasaweb added support for PNG (it used to not accept PNG files) and it seems to work correctly.
Probably you could fork another Inkscape, export as PNG, use ImageMagick to convert to JPEG and upload that JPEG, but it seems more trouble (and poorer) than using gdk-pixbuff.
Thanks guys. I would take a look at gdk-pixbuf as option.
It just struck me: is it possible to chain the extensions in inkscape? If that can be done then I can use Jpeg 'output' extension as 'input' for my extension. Don't know if that will make any sense in Inkscape's planned extension architecture, but worth a thought.
Thanks, Jayesh
On Dec 28, 2007 1:39 AM, Nicu Buculei <nicu_gfx@...2342...> wrote:
Jayesh Salvi wrote:
It is also a possibility to fork another inkscape instance as command line and use --export-png to convert to PNG (I think flickr/picasa will accept png). But the conversion result was very poor when I tried it. When the SVG image contained some simple black lines on a white background, the resultant PNG contained only black lines and no
background.
flickr will automatically convert at upload time the PNG to JPEG with a very poor result: you can't adjust the quality but, even worse, this will destroy the alpha transparency (blur shadows, antialiased edges), so this is not a viable option. Picasaweb added support for PNG (it used to not accept PNG files) and it seems to work correctly.
Probably you could fork another Inkscape, export as PNG, use ImageMagick to convert to JPEG and upload that JPEG, but it seems more trouble (and poorer) than using gdk-pixbuff.
-- nicu :: http://nicubunu.ro :: http://nicubunu.blogspot.com Open Clip Art Library: http://www.openclipart.org my cool Fedora wallpapers: http://fedora.nicubunu.ro/wallpapers/ my clipart collection: http://clipart.nicubunu.ro/
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
I have code to output jpegs via gdk-pixbuf. Its just not ready enough to hit 0.46 Would be happy to share what i have with you.
Cheers
John
On 12/29/07, Jayesh Salvi <jayeshsalvi@...155...> wrote:
Thanks guys. I would take a look at gdk-pixbuf as option.
It just struck me: is it possible to chain the extensions in inkscape? If that can be done then I can use Jpeg 'output' extension as 'input' for my extension. Don't know if that will make any sense in Inkscape's planned extension architecture, but worth a thought.
Thanks, Jayesh
On Dec 28, 2007 1:39 AM, Nicu Buculei <nicu_gfx@...2342...> wrote:
Jayesh Salvi wrote:
It is also a possibility to fork another inkscape instance as command line and use --export-png to convert to PNG (I think flickr/picasa
will
accept png). But the conversion result was very poor when I tried it. When the SVG image contained some simple black lines on a white background, the resultant PNG contained only black lines and no
background.
flickr will automatically convert at upload time the PNG to JPEG with a very poor result: you can't adjust the quality but, even worse, this will destroy the alpha transparency (blur shadows, antialiased edges), so this is not a viable option. Picasaweb added support for PNG (it used to not accept PNG files) and it
seems to work correctly.
Probably you could fork another Inkscape, export as PNG, use ImageMagick to convert to JPEG and upload that JPEG, but it seems more trouble (and poorer) than using gdk-pixbuff.
-- nicu :: http://nicubunu.ro :: http://nicubunu.blogspot.com Open Clip Art Library: http://www.openclipart.org my cool Fedora wallpapers: http://fedora.nicubunu.ro/wallpapers/ my clipart collection: http://clipart.nicubunu.ro/
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Thanks John, that will be great. Please let me know where can I get it.
Jayesh On Dec 29, 2007 11:23 AM, john cliff <john.cliff@...155...> wrote:
I have code to output jpegs via gdk-pixbuf. Its just not ready enough to hit 0.46 Would be happy to share what i have with you.
Cheers
John
On 12/29/07, Jayesh Salvi <jayeshsalvi@...155...> wrote:
Thanks guys. I would take a look at gdk-pixbuf as option.
It just struck me: is it possible to chain the extensions in inkscape? If that can be done then I can use Jpeg 'output' extension as 'input' for my extension. Don't know if that will make any sense in Inkscape's planned extension architecture, but worth a thought.
Thanks, Jayesh
On Dec 28, 2007 1:39 AM, Nicu Buculei < nicu_gfx@...2342...> wrote:
Jayesh Salvi wrote:
It is also a possibility to fork another inkscape instance as
command
line and use --export-png to convert to PNG (I think flickr/picasa
will
accept png). But the conversion result was very poor when I tried
it.
When the SVG image contained some simple black lines on a white background, the resultant PNG contained only black lines and no
background.
flickr will automatically convert at upload time the PNG to JPEG with a very poor result: you can't adjust the quality but, even worse, this will destroy the alpha transparency (blur shadows, antialiased edges), so this is not a viable option. Picasaweb added support for PNG (it used to not accept PNG files) and it seems to work correctly.
Probably you could fork another Inkscape, export as PNG, use ImageMagick to convert to JPEG and upload that JPEG, but it seems more trouble (and poorer) than using gdk-pixbuff.
-- nicu :: http://nicubunu.ro :: http://nicubunu.blogspot.com Open Clip Art Library: http://www.openclipart.org my cool Fedora wallpapers: http://fedora.nicubunu.ro/wallpapers/ my clipart collection: http://clipart.nicubunu.ro/
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
participants (4)
-
Dan H
-
Jayesh Salvi
-
john cliff
-
Nicu Buculei