After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 721354 - Suggestion to invoke cairo_surface_set_mime_data() to embed JPEG images
Suggestion to invoke cairo_surface_set_mime_data() to embed JPEG images
Status: RESOLVED FIXED
Product: librsvg
Classification: Core
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: librsvg maintainers
librsvg maintainers
Depends on:
Blocks:
 
 
Reported: 2014-01-02 18:05 UTC by suzuki toshiya
Modified: 2014-08-17 16:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch making rsvg_cairo_surface_new_from_href() to invoke cairo_surface_set_mime_data() (2.05 KB, patch)
2014-01-02 18:05 UTC, suzuki toshiya
none Details | Review
test SVG including 796KB JPEG image (628.11 KB, application/octet-stream)
2014-01-02 18:24 UTC, suzuki toshiya
  Details

Description suzuki toshiya 2014-01-02 18:05:36 UTC
Created attachment 265176 [details] [review]
patch making rsvg_cairo_surface_new_from_href() to invoke cairo_surface_set_mime_data()

Current rsvg_cairo_surface_new_from_href() creates a cairo surface from pixbuf data.
When href-ed data is JPEG, the pixbuf data is quite bigger than the source JPEG data.
Cairo avoids lossy reencodin, thus PDF generated by rsvg from a SVG including JPEG
image is very big, in comparison with the total size of the original SVG.
Because PDF can include JPEG images as they are, cairo has a function
to put JPEG image data to the surface without decoding it; cairo_surface_set_mime_data().
Attached patch modifies rsvg_cairo_surface_new_from_href() to invoke it.
If the function works without error, the surface originally filled by pixbuf data is
refilled by un-decoded JPEG data. If failed, pixbuf data is reused to refill
the surface as fallback.

Testing the modified rsvg-convert, the converted pdf of
tests/svg1.1/svg/struct-image-01-t.svg becomes smaller,
from 140kb (including decoded JPEG) to 7.5kb (including un-decoded JPEG).

Please review.
Comment 1 suzuki toshiya 2014-01-02 18:24:25 UTC
Created attachment 265178 [details]
test SVG including 796KB JPEG image

ah, tests/svg1.1/svg/struct-image-01-t.svg was not good benchmark.
here I attach a SVG file including 796KB JPEG image.
My patch reduces its PDF output size from 3.2MB to 800KB.
Comment 2 Christian Persch 2014-08-17 16:45:39 UTC
I committed a patch based on this, but making it controlled by a flag (so as to not inflate memory use when this feature is not needed).