SVG and media output not working on Windows

Bug #391307 reported by jazzynico on 2009-06-23
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

First commented in wishlist Bug #386664.

Using File>Save As>Compressed Inkscape SVG with media (file with imported images) leads to an invalid zip file, which contains only the beginning of an image file (PK♥♦¶ ₧╟:ë>╦ä♫▼ ♫▼ ► spiro_smooth.PNGëPNG) when opened in a text editor.
The bug is in the extension
It may be due to the fact that the zip file is first created in a temporary directory, and then copied to the final location using sys.stdout:

        out = open(self.zip_file,'r')

The temporary zipped file works well, but after opening it and writing it to stdout, it fails on Windows XP.
Works well on Ubuntu 9.04, rev. 21669.

jazzynico (jazzynico) on 2009-06-23
Changed in inkscape:
assignee: nobody → JazzyNico (jazzynico)
status: Confirmed → In Progress
Alvin Penner (apenner) wrote :

In windows if I force it to do a binary read using the statement :
out = open(self.zip_file,'rb')
instead of : out = open(self.zip_file,'r')
then I get the following zip file. This file is no longer empty, it apears to contain 2 files. But when I try to extract it then I get a crash in Winzip.

jazzynico (jazzynico) wrote :

Thanks Alvin.
'rb' is better than 'r', and the generated zip is almost correct but the LF, in the temporary file, are replaced by CRLF in the final zip...
I'm looking for a solution that keeps the stream intact.

jazzynico (jazzynico) wrote :

More precisely, CRLF are replaced by a CR and, on the "next" line, a CRLF. Even with binary mode!
On Ubuntu the temporary and the final files are identical (newlines are not modified).

According to this thread:
it's a known problem.
I've tested with 2.6.2, same behavior.

jazzynico (jazzynico) wrote :

Attached is a version of the file which should work on Windows. I had to add a special case this OS (again...) to handle binary output to stdout.
The script is not exhaustively tested (only on Windows XP) and thus not committed. I plan to finish the tests on Vista and Ubuntu later today.

jazzynico (jazzynico) wrote :

Fix committed in rev. 21704.
Please test and comment!

Changed in inkscape:
milestone: none → 0.47
status: In Progress → Fix Committed
su_v (suv-lp) wrote :

on OS X 10.5.7, Inkscape r21674: my test cases from bug #386664 export and zip ok with this version. All images are included in the archive and referenced with relative paths; utf-8 filenames are ok. ;-)

ScislaC (scislac) on 2009-11-24
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers