I have a few hundred images (mostly icons), and know for a fact that some have masks and others don’t (they show white background when viewed in “Preview”)
I have tried various techniques to try and find all the non-masked images, but to no avail
I can scan the directories and find all the files, load them as pictures
hasAlphaChannel // RETURNS TRUE FOR ALL IMAGES
dim m as picture=p.mask; if m<>nil then // RETURN FALSE FOR ALL IMAGES
these are all PNG images from 16x16 to 96x96 in size… on disk files, not ImageSets in the IDE
Dim dlg As OpenDialog
Dim f As FolderItem
Dim p As picture
Dim g As graphics
Dim x As Integer
Dim y As Integer
Dim i As Integer
Dim j As Integer
Dim f2 As FolderItem
Dim f3 As FolderItem
Dim f4 As FolderItem
Dim t As TextOutputStream
f=SpecialFolder.Desktop.child("xxx.trace_log")
If f.exists Then f.delete
t=TextOutputStream.Create(f)
f2=GetFolderItem("")
For i=1 To f2.Count
f=f2.TrueItem(i)
If f.Directory=False Then Continue
For j=1 To f.Count
f4=f.TrueItem(j)
If Right(f4.DisplayName,4)<>".png" Then Continue
p=picture.Open(f4)
Dim m As picture=p.mask(False)
t.writeline f4.parent.DisplayName+"/"+f4.DisplayName+"="+Str(m=Nil)
Next j
Next i
t.close
MsgBox "done "+Str(f2.count)
Quit
no need to be elegant… its a Q&D one-off (quick and dirty)
[quote=365990:@Christian Schmitz]Picture open on Mac does always use NSImage and give image with alpha.
So this will never have a mask.[/quote]
So the question is not whether it has a mask, but whether any of the pixels are transparent.
Well, if you use my plugins, you could try CGImageSourceMBS on Mac.
There you have properties per image, so you could check kCGImagePropertyHasAlpha key.
[code]dim f as FolderItem = SpecialFolder.Desktop.Child(“test.tiff”)
dim c as new CGImageSourceMBS(f)
dim d as Dictionary = c.PropertiesAtIndex(0)
dim b as Boolean = d.Lookup(c.kCGImagePropertyHasAlpha, false)
MsgBox "alpha: "+str(b)[/code]
So this checks for alpha status for various image types on macOS.
for the records, another way using the shell and the scriptable image processing system would be sips -g hasAlpha <path> that should be available on most *NIX incl. Darwin.