SVG and media output not working on Windows

Bug #391307 reported by jazzynico
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
jazzynico

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 svg_and_media_zip_output.py.
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')
        sys.stdout.write(out.read())
        out.close()

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)
Changed in inkscape:
assignee: nobody → JazzyNico (jazzynico)
status: Confirmed → In Progress
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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: http://mail.python.org/pipermail/python-dev/2007-September/074739.html
it's a known problem.
I've tested with 2.6.2, same behavior.

Revision history for this message
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.

Revision history for this message
jazzynico (jazzynico) wrote :

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

Changed in inkscape:
milestone: none → 0.47
status: In Progress → Fix Committed
Revision history for this message
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)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.