Forum: Inkscape Shrinking the results of JPG to SVG conversion

Db15e18793a09a11c8b4e5433f60e3e3?d=identicon&s=25 Pranav Lal (Guest)
on 2012-04-17 02:54
(Received via mailing list)
Hi all,

I have a number of *.jpg files that I need to convert to svg. I am using
inkscape for the conversion. The problem is that the resulting svg is
almost
5 times the size of the jpeg file. I have tried saving the file in
compressed plain svg but with no success. The file is still very large.
Is
there anything I can do to shrink the file? I have run an open source
cleanup tool called cleanSVG downloadable from codeplex but that has not
helped.

I am open to using other JPG to SVG converters if inkscape is not the
right
tool for this exercise. Natively creating SVG is not an option at this
point.
Pranav
C9af522fc39d5de90f21119543c2b9ab?d=identicon&s=25 Steve Litt (Guest)
on 2012-04-17 03:36
(Received via mailing list)
On Tue, 17 Apr 2012 06:23:26 +0530
"Pranav Lal" <pranav.lal@gmail.com> wrote:

> I am open to using other JPG to SVG converters if inkscape is not the
> right tool for this exercise. Natively creating SVG is not an option
> at this point.
> Pranav

Probably the resulting svg would compress well in a .zip or .tgz. I
think the problem is that  .svg is a vector format, .jpg is a bitmap
format, and a raw conversion would just make an XML description of the
bitmap. If you could hand-process the bitmap to turn parts of it into
vector objects, that would tremendously shrink the .svg.

Thanks

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance
827edb15a6cb37b669fddc2008150102?d=identicon&s=25 Auguste Pop (Guest)
on 2012-04-17 04:00
(Received via mailing list)
On Tue, Apr 17, 2012 at 8:53 AM, Pranav Lal <pranav.lal@gmail.com>
wrote:
> I am open to using other JPG to SVG converters if inkscape is not the right
> tool for this exercise. Natively creating SVG is not an option at this
> point.
> Pranav
>

how did you do the "conversion"?

as far as i know, you can directly embed your binary jpeg file inside
svg with base64 encoding. that way, the result svg file should not be
much larger than the original jpeg file.

i am not sure how to do this in inkscape. but you should be able to
write a small script to do this.

best regards,
1725020ed58eea0c8e31f86ba702cb69?d=identicon&s=25 Jon Cruz (Guest)
on 2012-04-17 06:24
(Received via mailing list)
On Apr 16, 2012, at 7:00 PM, Auguste Pop wrote:

> how did you do the "conversion"?
>
> as far as i know, you can directly embed your binary jpeg file inside
> svg with base64 encoding. that way, the result svg file should not be
> much larger than the original jpeg file.
>
> i am not sure how to do this in inkscape. but you should be able to
> write a small script to do this.

That's usually not really a good approach.

Embedding a binary jpeg file in an SVG file expands it by 33%, not to
mention various in-memory issues that can arise. Of course, 133% is not
nearly as bad as 500%, but it's generally not as helpful. For editing,
it can really cause problems, as in-memory string storage can go way up.
Db15e18793a09a11c8b4e5433f60e3e3?d=identicon&s=25 Pranav Lal (Guest)
on 2012-04-17 07:00
(Received via mailing list)
Hi all,

Many thanks for your responses. I am on gmail's web interface as of
now so am responding to all the posts so far in a single message.

I am trying to imbed Images in an epub book. This book could be read
on a variety of devices so I am hoping to use SVG to render the image
correctly (for want of a better word) on each device the book is
opened. The book will be transmitted over the Internet in a low
bandwidth situation so I am trying to shrink the SVG files.

As for the conversion, I am using the -l commandline option to produce
plane svg.

I would love to be able to convert some of the SVG to objects but have
not found an automated tool to do this. I could write my own using
shape recognition algorithms but that is my last resort.

Pranav
1725020ed58eea0c8e31f86ba702cb69?d=identicon&s=25 Jon Cruz (Guest)
on 2012-04-17 08:10
(Received via mailing list)
On Apr 16, 2012, at 9:59 PM, Pranav Lal wrote:

> plane svg.
>
> I would love to be able to convert some of the SVG to objects but have
> not found an automated tool to do this. I could write my own using
> shape recognition algorithms but that is my last resort.

That tells us on how you save the SVG once it had been created, but not
how the SVG was originally done.

The usual way is to use the 'Trace Bitmap' functionality on an imported
jpg and then removing the reference to the jpg.
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Trace.html

The main place to gain size reductions is in the initial conversion.
Sometimes this also can be aided by cleanup or simplification of the
image before tracing.
Db15e18793a09a11c8b4e5433f60e3e3?d=identicon&s=25 Pranav Lal (Guest)
on 2012-04-17 08:39
(Received via mailing list)
Hi Jon,
<snip
That tells us on how you save the SVG once it had been created, but
not how the SVG was originally done.

The usual way is to use the 'Trace Bitmap' functionality on an
imported jpg and then removing the reference to the jpg.
PL] Thanks for your response. The original image is a Jpeg file which
I am opening in inkscape.

Pranav
2cb59b460a7d0e5fdf6a037279395205?d=identicon&s=25 Bats Man (bats)
on 2012-04-17 09:17
(Received via mailing list)
On 17/04/2012 08:38, Pranav Lal wrote:
> The usual way is to use the 'Trace Bitmap' functionality

Just watch the size and complexity of the traced result. It can be very
slow with thousands of little curves.

I forget the terms now, but you can dial-down the sensitivity to 'dots'
and such, which is worth doing.

Play with the settings in the trace dialog. Each kind of image has a
better approach. For example those with few colours can be clamped to
only tracing 2 or 4 colours.

I have seen SVG files that are bigger (much) than the original image
file. It's all in the number and length of paths really.

A large, complex trace is going to eat memory too -- so the viewing of
such traces may be a problem on your client side.

\d
Cc1bcf40451d6c18fe3a4e40cf8bdcac?d=identicon&s=25 Nicu Buculei (Guest)
on 2012-04-17 10:35
(Received via mailing list)
On 04/17/2012 09:38 AM, Pranav Lal wrote:
> Hi Jon,
> <snip
> That tells us on how you save the SVG once it had been created, but
> not how the SVG was originally done.
>
> The usual way is to use the 'Trace Bitmap' functionality on an
> imported jpg and then removing the reference to the jpg.

> PL] Thanks for your response. The original image is a Jpeg file which
> I am opening in inkscape.

If your images are photos, then SVG probably is not the right format for
them, the result will be huge and at a bad quality.
If the images are drawings, then the best is to trace and then manually
adjust the result (or even redraw them - a manual trace).

--
nicu :: http://nicubunu.ro :: http://nicubunu.blogspot.com
Db15e18793a09a11c8b4e5433f60e3e3?d=identicon&s=25 Pranav Lal (Guest)
on 2012-04-19 18:15
(Received via mailing list)
Hi nicu,

the images are phhotos. The reason I am converting to SVG is that if I
understand things correctly, it will scale better on a variety of
devices
and screen sizes.

Pranav
C9af522fc39d5de90f21119543c2b9ab?d=identicon&s=25 Steve Litt (Guest)
on 2012-04-19 20:05
(Received via mailing list)
Hi Pranav,

That would be true of a from-scratch SVG that's truly a vector graphic,
but I don't think it would be true for an SVG'ized JPG that's basically
an SVG wrapper around a JPG bitmap. I think you mentioned earlier in
this thread that your photos are over a megabyte in size. That should
scale pretty well on everything but the biggest screens.

You never mentioned whether these will be used in a website, a PDF
document, an EPUB book, or something else. Where will they be used?

SteveT

On Thu, 19 Apr 2012 21:43:29 +0530
Ce46b00567f432f27d990fcc183c806e?d=identicon&s=25 Tommy Hjalmarsson (Guest)
on 2012-04-19 23:50
(Received via mailing list)
Steve Litt skrev 2012-04-19 20:04:
>
>>
>>> Hi Jon,
>> If the images are drawings, then the best is to trace and then
>> http://p.sf.net/sfu/Boundary-dev2dev
>> http://p.sf.net/sfu/Boundary-d2dvs2
> _______________________________________________
> Inkscape-user mailing list
> Inkscape-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/inkscape-user
>

First:
http://zombiwoof.deviantart.com/gallery/12392182#/d46z8l2

The image is a SVG file, all vector, but "I" made it, a human. No trace
program today can trace a photograph and do it to vector with this
quality.

Vektor for webb is mostly logotypes, illustrations that have few colors.
Trace photographs to vector can bee a expression, a manner. But they
have few colors, like two or a few more/, but not //16,7 million colors
as a bitmap can have. ///If you for example set the trace program to 6
million colors (I don't think it's possible) then you have SVG file with
so much code, it's humungous, and for the web browser to read the code,
and download it take time, a lot of time.

//Tommy Hjalmarsson/
//
Db15e18793a09a11c8b4e5433f60e3e3?d=identicon&s=25 Pranav Lal (Guest)
on 2012-04-20 03:16
(Received via mailing list)
Hi Steve,

The photos will be used in  epub books that will be read on mobile
phones.

Pranav
1725020ed58eea0c8e31f86ba702cb69?d=identicon&s=25 Jon Cruz (Guest)
on 2012-04-20 07:09
(Received via mailing list)
On Apr 19, 2012, at 6:12 PM, Pranav Lal wrote:

> Hi Steve,
>
> The photos will be used in  epub books that will be read on mobile phones.
>
> Pranav


If they convert to vector that is smaller, than changing them is good.
If not, then keeping the bitmap version as jpeg and just wrapping it in
an SVG container might be best.

This article

http://denis.papathanasiou.org/?p=592

recommends this simple type wrapper:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%"
viewBox="0 0 592 900" preserveAspectRatio="xMidYMid meet">
<image width="592" height="900" xlink:href="images/page01.jpeg" />
</svg>
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.