Find All Images With Given Attributes

I’m an iOS developer and with the release of Xcode 8 came a little issue. Apple introduced wide-color support on iOS 9. This meant that if you had 16 bit images then you couldn’t target older iOS versions, otherwise you would see something like this:

ERROR ITMS-90682: Invalid Bundle - The asset catalog at ‘Payload/XXXXX/Assets.car’ can’t contain 16-bit or P3 assets if the app supports iOS 8 or earlier.

So this prompted the need for me to easily find 16-bit images. Apple did help with that but it was really Xcode-project specific and I wanted to have something more generic.

Note For iOS Devs (Others can skip) #

For those of you who are finding this page because you’ve had this error, do also check this page: https://forums.developer.apple.com/thread/60919?tstart=0 and note the following:

If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will receive this same error message, even if you do not actually have 16-bit or P3 assets. In this case you will either need to lower your Deployment Target to 8.2, or move it up to 9.x.

Finding Images #

I came across ImageMagick. You can install it using MacPorts of Homebrew:

brew install imagemagick

It took me a few minutes and I composed this command:

find ./ -iname "*.png" -type f -exec identify -format '%depth %i' '{}' \; | awk '$1=16{print $1 "-bit:", $2 "\n"}'

This essentially prints all the png images in all subfolders that are 16 bit! let’s break it down a little:

Other Searches #

You can use this tool to search for images by size or other properties. Here’s an example of a command that searches for images that are 1024 by 1024 pixels.

find ./ -iname "*.png" -type f -exec identify -format '%w %h %i' '{}' \; | awk '$1=1024 && $2=1024 {print $1, "x", $2, ":", $3, "\n"}'

Sources & Useful Links #

 
5
Kudos
 
5
Kudos

Now read this

Anagrams/C++

This weekend I decided to refresh on C++ in preparation for some interviews. I tried to pick a project that I could code in roughly one day. It should not only have me review C++ but force me to solve some problems and implement some... Continue →