Xcode 6 asset catalog automatically create images for smaller scales

12,868

Solution 1

I ended up making a small mac app that takes care of the dirty work. You can drag and drop one or multiple .jpg or .png files into the app's main view; it will detect the input image's scale and create the smaller scaled images. With this app I only need to create a single, 3x image and drag it into the app to create the two smaller images. It saves so much work!

The source can be found on my GitHub page, simply download it and run it on your mac! https://github.com/JonasGessner/ImageReducer

Solution 2

There is another way to solve this problem.

Use Automator to create Mac OS X service which create @3x, @2x and normal image on base of 1 image in @3x resolution automatically. It use just 3 methods: duplicate images, scale down, and rename.

Ready Mac OS X service made in Automator you can find here:

https://github.com/lukszar/iOS-Images-Prepare

Solution 3

late to the party but there is one tool which make all assets @1x, @2x, @3x and icons for you in just one click. And also export to XCAssets file.

You can find it here: https://github.com/angelvasa/AVXCAssets-Generator

enter image description here

Hope this will help someone

Share:
12,868
JonasG
Author by

JonasG

iOS app developer.

Updated on June 08, 2022

Comments

  • JonasG
    JonasG almost 2 years

    With the need of 3x images in iOS 8 I figured it would be easier to manage images with an asset catalog in Xcode 6. I am trying to just provide a single image, the 3x scaled image to the asset catalog and I want Xcode to automatically downscale that image to generate 2x and 1x versions of the 3x image, so that I don't have to do it manually.

    Right now this is what I have:

    I really hope that Xcode has such a feature to automatically create 2x and 1x images and I just have not discovered it yet. If there isn't any such feature, are there any alternatives? (I know IconKit but it is annoying and hasn't been updated to support 3x images. If it was made properly in the first place it wouldn't even need an update..)

    I know that Xcode automatically can generate all images from a vector pdf, but thats not what I am looking for!

    • newenglander
      newenglander about 7 years
      IconKit has since been updated for 3x images.
  • JonasG
    JonasG over 9 years
    Downscaling at runtime is really bad for performance, and I am not even sure if thats the default behavior of iOS. Thanks anyway!
  • Zev Eisenberg
    Zev Eisenberg over 9 years
    Yes, my point was that it will probably work, but it would look bad and you shouldn’t do it if you care about your app looking nice. (But for a test project, totally workable.)
  • JonasG
    JonasG over 9 years
    Fortunately I care a lot about my app looking nice ;) Yeah I get what you mean; it could be possible but it's definitely not the way to go.
  • JonasG
    JonasG over 9 years
    Nice, I also made a mac app to do the same, it's on GitHub: github.com/JonasGessner/ImageReducer
  • Zev Eisenberg
    Zev Eisenberg almost 9 years
    iOS will do this for you: if you leave out an image size, it will load the next appropriate size. You will be scaling in software, and so will technically incur a performance hit, but most of the time you will probably not notice it.
  • Declan McKenna
    Declan McKenna over 8 years
    Thanks for sharing this, I'm saving so much time :)
  • lukszar
    lukszar over 8 years
    I am glad to hear that :-)
  • Ely Dantas
    Ely Dantas about 3 years
    @JonasG Hi, I just clonned your repo, drag+drop functionality is not working and it's the only way to import images :(