Image Resource Analyzer [24Sep]

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:

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

Handy tool.
I was amazed at how many unwanted items there were, but found that a good number in my project were only referenced as parameters into methods.


Call   AddAButton "Save",picSavePicture

didn’t trigger a ‘referenced’ count

Thanks… I will add that… should be difficult
will post a new version later today

This fixes the issue Jeff mentioned, as well as other circumstances where the image reference is an argument.

Note : it properly ignores situations where the reference name appears in a quoted string.

Nice ! I love this feature… :wink:

FYI… while I offer this freely :slight_smile:
Donations will not be turned down :smiley:

Does this line confuse it?
a_algerian is reported as unused.

(I thought it might be case sensitive at one point, but that wasnt it…)

g.drawpicture a_algerian ,2,1,g.height-2,g.height-2,0,0,a_algerian.width ,a_algerian.height

in testing, removing the ’ _’ didnt change things, nor did replacing the a_algerian.width ,a_algerian.height with constants.

No… that syntax was actually one of the first ones I tested…
However this latest update includes a Tokenizer (from a past project) to process SOURCELINES now

I just ran my test program again, it it works for me :frowning:

g.DrawPicture dark_add1x   ,0,0

// comment
Dim p As picture   =   lite_add1x
Call test 1 ,headshots , 3

dim a as string=" dark_add1x "

my test program also includes 3 unused images

if “a_algerian” a resource in the IDE? or is it a picture that your app creates on the fly?
my app won’t find the second type as there is no permanent reference to look for

[and THANKS :)]

There are another 12 similar images that suffer the same way
I’ll see if I can find a common aspect

Right now, my process is run your app, search my app, agree or disagree with your assessment,
then rename the image as zz and try to compile.
Any that go bink get renamed back.

Even that process is still going to result in a good wodge of images no longer needing to go into the compiled build…

Something odd happens with images used in a segmented control.

could you send me your code (full NDA of course, and I will destroy the files once this is solved)

and the process you are using is EXACTLY what I am doing as well… the first run of this found 20 images I could (and did) remove safely

opps… seems it did break DRAWPICTURE :frowning:

I think its ‘code inside a class’
Sending you a cut down bit of code in a mo.

Hmmmmm… Segment controls seem to encode the segment values some how

yes they do
in XML try decode hex - thats why the entry is tagged as “Hex” bytes
each “segment” is separated by &u0D
within each segment you’ll find other separators for each “field” - usually this is &u0A

THANKS… I had just figured out where the iconname was… but that helps alot :slight_smile:

any other place where an image resource might be in a block?


and apparently, use of an image as the mask for another image.

[quote=455004:@Jeff Tullin]myimage.getdata(picture.FormatTIFF)

and apparently, use of an image as the mask for another image.[/quote]
not sure I’m understanding that situation???

In the (old) IDE you could add an image, and set it to be transparent = 1 (white is transparent)
But the image also had a mask property in the inspector, where you could assign a black and white image of the same size as a mask, selected from other images that were in the project.

[quote=455001:@Dave S]THANKS… I had just figured out where the iconname was… but that helps alot :slight_smile:
any other place where an image resource might be in a block?[/quote]
well hex blocks are just blobs of data and they are specific to the particular kind of control/resource in use
there could be other places but I cant think of any off the top of my head

There is another new version on its way.
Various people (Thanks Jeff) have found other situations I had not thought of…
Such as SegCtrl icons and Mask for old style picture resources.