Image Resource Analyzer [24Sep]

Dave:
did you try to save projects (and read them from these files) as Text project files ?
There also may be some things to learn from there.

I found a bug in a project I use everyday (but not this feature) justbecause of that: I forgot a case in the list :frowning: or ;).

havent tried it but do you catch all the uses where its not done by name ?
for instance, the backdrop of a window is the ID of the image, not its name

 <PropertyVal Name="Backdrop">571852799</PropertyVal>

as is the backdrop of a canvas, the image assigned to an imagewell, the icon assigned to a menu item, the image assigned to a report picture, the icon on a tool bar button

you can find the image id in the header

<block type="MultiImage" ID="571852799">

or in a picture

<block type="Picture" ID="1974317055">

Yes… it searchs for names and ID codes which are used in PROPERTYVAL, ICON and MASK tags

A new version is available.

Fixed

  • find ICONS for segmented controls
  • find MASK images for Pictures
  • expanded the report to show if used in a property or in source code
  • added App Logo
  • added DarkMode (hey why not)

available at the original link above

fwiw I’d just add the link to each post of a new version as once they start to scroll off the top getting to the original post & link is a pain

[quote=454937:@Dave S]I have an app with hundreds of icons and images in ImageSets… Over the course of developing this, I have added more, decided not to use some etc… And realized that there were some images that I wasn’t using, but were still in the project.

So I developed a quick and dirty app to analyze a Xojo Project (XML format only) to determine what Imagesets (or stand alone Pictures) are declared in the project, and then attempt to find which ones are actually used

To be considered used. the image reference must be in one of the following situations

  • a property value of a control (a canvas backdrop for example)
  • on the right side of an assign ( p=myImage )
  • used in a DrawPicture command

If you can think of any other situation, please let me know

In the mean time here is a zip file containing both macOS and Windows executables for your pleasure :slight_smile:

www.rdS.com/Image_Resource_Analyzer.zip

NOTE : I take no responsibility for how you use the output of the report that is produced. Please verify any results before deleting images from your projects

NOTE : I have tested the macOS version, but not the Windows one, but there should be no differences[/quote]

Wanted to help out :slight_smile:

Image Resource Analyzer is Free to use.

can be downloaded from this link
www.rdS.com/Image_Resource_Analyzer.zip

Zip contains both macOS and Windows executables (both 64bit)

While its free, I do accept donations :slight_smile: , totally optional
www.rdS.com/donate.html

Ok… I made quite a few updates yet again…

Image Resource Analyzer is Free to use.

can be downloaded from this link
www.rdS.com/Image_Resource_Analyzer.zip

Zip contains both macOS and Windows executables (both 64bit)

While its free, I do accept donations :slight_smile: , totally optional
www.rdS.com/donate.html

Output is now expanded, and in HTML instead of ASCII text.

What is the oldest supported Xojo version ?

It should go way back… since other than ADDING IMAGESETS, the XML format I do not believe has changed… So older projects won’t find imagesets as there won’t be any, and everything should be “Picture” type

I tried a project from 2007r4 BUT it didnt like the extension apparently and said it was an invalid Xojo project (its not but …)
Changed the extension to xojo_xml_project and it opened and analyzed the project just fine

So except for the false “this isnt a xojo project” it seems it can go a long way back

Dave - maybe open the xml and see if it contains a “RBProjectVersion” node ?

The XML projects from that era just have an “xml” extension

Norman… good idea… because yes this version requires that specific extension

Ok… here we go yet again :slight_smile:

This version does not rely on the file extension, but instead looks “inside” as Norman suggested above. So it should work with just about ANY past version of RealBasic/RealStudio/Xojo that uses a variation of the current XML project file format. The output report also now tells you what version was used to last save the program being analyzed.

In 2015r1 it report 28 images and 14 are not referenced, 14 are.

Unfortunately, all of them are referenced (I think, I checked two or three). The one I recall is displayed into a Canvas using g.DrawPicture and the image was - like all others - imported into the project. That image (and two others “not referenced”) is displayed in my about window…

For the file type, I forgot it only reads xml projects, so after getting the error message, I exported to xml the project and it gives the result above.

HTH.

I’m sure providing an example that doesnt work to Dave would aid him immensely in tracking down whatever issue there is :slight_smile:

The best way to use this app is to rename, rather than immediately delete, the apparently unused images.
Prefix them with zz or similar.
Try to compile.
If compiling works, save the project with a new name
Then delete the zz items and try to compile again.
If it is still ok, save with a new name and move on.

(Off topic, having done this, I was able to remove 60 images from one project.
But the size of the built and packaged app went up by a few Kb! Must be some artefact of the compression algorithm.)

I’ve done that and I hope this will help. The trouble have been removed between Applications versions, but I provided full explanations from my methodology.

Sorry Emile , your “explanation” did not help… as a matter of fact I am still confused as to if your believe there is an issue or not. And since you can’t/won’t supply an example project I have no way of knowing if your code has a valid image situation that I need to modifiy my code to locate properly.

If your project has EXTERNAL MODULES and the only image references are in those modules, the current version of IRA will tag them as un-used.

Today I will see if I can compensate for this

EDIT : doesn’t seem likely, as external seems to only be stored in BINARY format, which is beyond the current scope of IRA to decode. The same will hold true for any ENCRYPTED modules. So the only way would be to create a “copy” of your app, Import all the externals, Decrypt any encrypted modules and save as XML

As a project may include EXTERNAL modules (stored in BINARY format), and or ENCRYPTED modules, neither of which can be read by the Image Analyzer. If a project contains either/both of these types of modules and unaccounted for images, a warning similar to this will appear in the HTML report

[quote]
NOTE : This project has one EXTERNAL module and one ENCRYPTED module which contain code that is not accessible to this analysis. These modules may contain image references that could not be accounted for below.[/quote]

Image Resource Analyzer is Free to use.

can be downloaded from this link
www.rdS.com/Image_Resource_Analyzer.zip

Zip contains both macOS and Windows executables (both 64bit)

While its free, I do accept donations :slight_smile: , totally optional
www.rdS.com/donate.html