Opened bitmap images get overwritten with svg on save without warning

Bug #429529 reported by Guillermo Espertino (Gez)
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Critical
theAdib

Bug Description

If a bitmap image is opened via the file>open command, it will be overwritten with SVG data if the user uses the command save, without any warning.
This is a critical bug, in my oppinion, since it destroys the bitmap data in the process, without a chance to recover it.

Steps to reproduce:
- [File > open] a jpg file
- create a single rectangle on it
- press CTRL+S

As a colateral damage, the garbled file hangs nautilus.

Tags: saving
Changed in inkscape:
importance: Undecided → Critical
description: updated
description: updated
description: updated
Revision history for this message
su_v (suv-lp) wrote :

Confirmed with Inkscape 0.46+devel r22221 on OS X 10.5.6

> As a colateral damage, the garbled file hangs nautilus.
Because the now SVG document still has the JPG or GIF or PNG file ending.

Another collateral damage: Inkscape cannot reopen the previously saved file: it gets completely unresponsive when reopening the image via 'File > Open Recent' (I know there is a separate bug filed for this but haven't searched yet).

Changed in inkscape:
status: New → Confirmed
tags: added: saving
Revision history for this message
Jon A. Cruz (jon-joncruz) wrote :

I believe that the essence of the problem here is that it should be treated as an "Import" and not an "open".

Revision history for this message
Pablo Trabajos (pajarico) wrote :

I agree with Jon Cruz. Opening directly documents like PDF is still handy because you can save directly to it when you want to overwrite it (which means you don't have to use 'Save as' or 'Save a copy' every time you want to save the file ). But for bitmaps is only destroying the information.

Revision history for this message
Guillermo Espertino (Gez) (gespertino-gmail) wrote :

Yes, I agree too. Bitmaps should be imported only (but I suspect that a carefully designed specification for opening/import is needed). Is there some way to avoid the data corruption in this particular situation in a short term?

Revision history for this message
Alvin Penner (apenner) wrote :

I cannot reproduce this problem on Windows XP, Inkscape 0.47pre2.
- open Inkscape, open .jpg file
- translate image slightly, click on File -> Save
- instead of saving it, the Save As ... dialog comes up, in which the default format is svg and there is no danger of accidentally overwriting the file.

- same behaviour occurs with a png file.

- however, if I open an .svg file in this way, then the modified file will be saved immediately with no warning, as expected.

Revision history for this message
su_v (suv-lp) wrote :

> cannot reproduce this problem on Windows XP
is this related to the mentioned changes in bug #229788 ? (i.e. on win32 'Inkscape doesn't support JPG and BMP export (they can only be imported) and the "guess from extension" is not in the 0.47 list of formats.')

Revision history for this message
Alvin Penner (apenner) wrote :

just writing to confirm that on Windows, in the Save As ... dialog :
- there is no "Guess from Extension" option
- Cairo PNG output exists (and works)
- .jpg and .bmp output do not exist

Revision history for this message
Lawrence (annon0m0s) wrote :

Confirmed this happens in Windows Vista with Inkscape 0.47pre2 r22153, built Aug 24 2009. I opened an existing document (a jpg), added a couple of vectors and pressed the save icon by habit. The original jpg still shows on the screen for a while but if the window is minimized and restored the image is replaced by "Linked image not found." I assume to save memory the image is discarded when the window is minimized and then refreshed from the file but the file has been changed. The original jpg is gone.

Revision history for this message
su_v (suv-lp) wrote :

*bump* - this happens so easily! Just opened a screenshot PNG to annotate, clicked the 'Save' button reflexively and the bitmap file is gone, overwritten with a self-referencing SVG document. Any chance we can get this fixed? Or - as Gez said so eloquently: «Is there some way to avoid the data corruption in this particular situation in a short term?»

Inkscape 0.46+devel r22498 on OS X 10.5.8

Revision history for this message
theAdib (theadib) wrote :

hello all, attached a small patch that disables the automatic SVG when no extension found for the filename appendix. In this case the errormessage pops up and after pressing ok the "save as" dialogue appear. What I don't know jet that even I have the "automatic filename extension" switch ON the filename extension does not change :-? However the patch is fairly simple but I do not know in which other cases now this new dialogue traps.
Adib.

Revision history for this message
su_v (suv-lp) wrote :

testing patch with Inkscape 0.46+devel r22514 on OS X 10.5.8

- Prompting to save as SVG works correctly when closing the window after making any changes.
- What surprises me: new (to me ;-) bitmap editing features of Inkscape…

1) quick export with 'Save' button:
open PNG, draw a vector object overlapping the bitmap, click the 'Save' button on the commands bar: bitmap on disk gets immediately overwritten as if I used 'Export Bitmap… > Drawing': Size unchanged, updated with the overlapping parts of the added objects.

2) crop/resize raster image within Inkscape:
Open PNG file using the 'File > Open…' dialog. Open 'File > Document Properties… > Page' and change the page 'Format' to a 'Custom size', e.g. clipping the height but extending the width. On canvas the bitmap is still shown with the original size but the page size (borders) now changed. Click 'Save' on commands bar. View the newly saved PNG outside of Inkscape with an image viewer: the bitmap has been cropped and extended as the page contents of the Inkscape canvas show. Back in Inkscape use 'File > Revert' to trigger a reload of the bitmap. Result: you have successfully cropped a raster image within Inkscape. Note: the extended parts of the raster image are filled with solid white, not with transparency. You can resize, stretch, scale the image and the 'Save' button will always export the page as bitmap, overwriting the initially loaded file.

Did I miss this before or was it just not possible with the "automatic SVG when no extension found for the filename appendix"?

Revision history for this message
theAdib (theadib) wrote :

suv, the png save is different than the "export as bitmap".
save as png is done by cairo-exporter and so a little bit different than the native png export.

So this feature you probably did not notice.

Png save was always there. There is no jpg save. So jpg was overwritten by svg. FYI Check the fileformat drop down box.

Adib.

Revision history for this message
su_v (suv-lp) wrote :

*embarrassed* you are correct - I confused the results of the 'Save' command on directly opened PNG and GIF images from earlier tests. And must have been blind regarding the PNG editing feature (I had noticed the Cairo PNG file format though and knew that there is no export extension for JPG, the same goes for GIF… stupid me ;-).

Testing 'Save' button with JPG (or GIF) image now prompts with an error message (attached) and then opens the 'Save as…' dialog with 'Inkscape SVG' as proposed file format. Doesn't change the file name extension though and would still overwrite the JPG (or GIF) file if allowed - as you mentioned in comment #10.

Much better solution then silently overwriting the bitmap file with SVG content - thank you for taking a look at this!

Revision history for this message
ScislaC (scislac) wrote :

Fix committed in 22516

Changed in inkscape:
assignee: nobody → theAdib (theadib)
status: Confirmed → 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.