Remove unwanted image file from within MuseScore file

• Mar 13, 2021 - 17:57

Yesterday I placed several large images in my file. Today I found a better, smaller images.
I replaced the former images.
The MuseScore file [size] is now bloated.
Is there any way to remove the previous versions of the images. I imagine that they are stored in my infinite undo list.


Comments

In reply to by Shoichi

Thanks. The Del, removes the image from view, but leaves the file of the image, probably in an archive, somewhere, because using undo allows the user to go back an unlimited number of steps. When closing a MuseScore file, the undo steps are not removed.
Is there a 'clear undo list' command?
With similar problems in other programs, I have set the undo list to two steps, made two changes and saved. All of the old steps are removed from the file.

In reply to by Marc Sabatella

In a way, the undo stack does play a part in the reason why this is happening, but it is not because the undo steps are saved in the file (they are not). Rather, it is because the global image store has no way of knowing whether a particular image is actually being used in its associated score, or if it is only being kept alive in the undo stack. But this is easily remedied. And there does not have to be code to remove the image from the archive, because the archive is recreated from scratch every time the file is saved.

In reply to by Jojo-Schmitz

Thank you.
If, once the image has been deleted from the file, it is no longer accessible in any way, then the automatic deletion from the library seems a good idea.
However, if there is some way of accessing the image on another occasion, in my experience, the removal of the image from the library should be an option, rather than a defined consequence. Upon deleting the image, the dialog box, something like, [[ : Remove from file : Delete from library : Cancel ]] will let the user decide.

In reply to by kevin.austin@v…

All this does is make sure that the deleted image is not saved in the MSCZ file. The image store does not persist between sessions, and an image store item is deleted automatically when its reference count drops to 0. Reference counts are decremented when the image object is deleted or goes out of scope, but this will not happen as long as the image object is being kept alive in the undo stack. So the removal of image store items really only happens when a score is closed, and only for items that are not in use in other open scores.

I would recommend removing the images and saving as MSCX, which is the text-only format that the MSCZ archive is based on. Then load that MSCX and add the images, then save as MSCZ. You could also use a ZIP tool to simply remove the image from the MSCZ archive.

In reply to by Marc Sabatella

Thank you. This has been a most informative thread. I saved a copy as MSCX and reopened. The images were gone, and the placeholder frames remained in place. The file was reduced to 10% of its MSCZ size. It is a bit of a sledgehammer approach as it removes all of the images' files. Fortunately, in this piece, at the moment I only have 11 images, but to solve a notation problem in parts of the piece I had planned to add a number of images. I will rethink the work plan before doing this so as not having to replace all of the images in the score.

My skill level is not high enough to understand using a ZIP tool to remove images from the MSCZ archive.

This is a pretty obscure problem and that could be the reason it is not in the support documentation. I will know from here on to plan my image additions in much more detail before placing them in a score.

Kevin

In reply to by kevin.austin@v…

It's pretty obscure indeed,. but probably we should be better about cleaning up no-longer images automatically.

For future reference, ZIP tools require no special technical skills to use. , just open up the MSCZ in one, it shows you a list of files, you find the ones you don't want and remove them. if you can delete files from your computer using Windows Explorer or Finder or whatever, it's the same thing.

In reply to by Marc Sabatella

I'm on Mac. I looked at the hidden files and could only see a .MSCZ format and a [smaller] .MSCX format. Possibly the files you are referring to are inside other folders.
I will leave this for now as there are other more important deadlines.
Just as a general comment however, I find the manual is often a 'fight' to find things. I come with similar concepts [from Finale], but with different terminology.

In reply to by kevin.austin@v…

Unfortunately I don't know macOS well. On other OS's, I'd expect you could right-click (Ctrl+click for macOS, I know that much) the file in your favorite file browser (e.g., Finder) and see a popup menu that contains an option like "open archive"). Upon doing that, I'd expect the contents of the archive to be displayed just as if I had opened a folder and was now looking at its contents. Then I'd just find the file I wanted to delete and delete it normally.

In reply to by Marc Sabatella

This problem is not so obscure. I use images on all my scores and have had .mscz files inflate to 6 MB. But the methods above have solved my problem. I now reduce my images in size to 700x700 pixels. Then BEFORE inserting them I open the .mscz file in a ZIP-programme and delete all the image files in the folder "Pictures". If I changed or improved my image I have found up to 4 image files here - that is the root of the problem and the ZIP-solution above solves it every time. Thanks! A huge relief after spending several hours trying to work around this.

This wasn't added into 3.6, but it was into 3.x in 2021 which apparently people use for the "3.7" that was available for a few years on the main repository as PR#9000 (Jojo Schmitz)

I'm here to give a warning
Images will be removed upon saving after loading a score with images using the PR posted by Matt. So anyone using 3.7 or 3.x code ought to be aware of that.

1) Add image to score + save
2) Close score, reopen, then Ctrl+S
The mscz archive will have removed the image so that next open will give nothing

Do you still have an unanswered question? Please log in first to post your question.