Giter Site home page Giter Site logo

ios2android's Introduction

ios2android

A simple script to port iOS retina images to the appropriate Android density buckets.

Porting an iOS application to Android is a time-consuming task, especially when you have to manually resize 1000 images from iPhone/iPad dimensions to Android density buckets and screen sizes. This script aims to save as much time as possible by automatically resizing these images for you.

Prerequisites

ImageMagick

On Mac OS X, the easiest way to install ImageMagick is with Homebrew:

brew install imagemagick

Usage

  1. Put the ios2android bash script somewhere in your path

  2. Copy the retina iOS images you want to convert into an empty directory.

  3. From a terminal, cd into that directory and run:

$ ios2android

The script will evaluate each file in the directory, and determine if it is targeted for phone or tablet devices based on the filename. It will then create resized versions of the images and place them into the appropriately named density bucket folders. The script will also compensate for filenames that are not valid in android (such as images starting with numbers or containing hyphens).

Once the script is complete, simply copy the new folders into your Android project and you will have the equivalent of the iOS images. Way easier than manually scaling it yourself!

You can also create phone images directly from iPad images by specifying a scaling factor to use. Take a look at example 3 below.

Example

  1. A directory containing the following files:
[email protected]         (510 x 490 pixels)
intro_text@2x~ipad.png    (1222 x 1152 pixels)

will result in:

drawable-mdpi/intro_text.png          (255 x 245 pixels - 50%)
drawable-hdpi/intro_text.png          (383 x 368 pixels - 75%)
drawable-xhdpi/intro_text.png         (574 x 551 pixels - 112.5%)
drawable-large-mdpi/intro_text.png    (611 x 576 pixels - 50%)
drawable-large-hdpi/intro_text.png    (917 x 864 pixels - 75%)
drawable-large-xhdpi/intro_text.png   (1375 x 1296 pixels - 112.5%)
  1. iPhone 5 4" images are treated the same as iPhone for 3.5" images, so a directory containing the following files:
[email protected]         (510 x 490 pixels)

will result in:

drawable-mdpi/intro_text.png          (255 x 245 pixels - 50%)
drawable-hdpi/intro_text.png          (383 x 368 pixels - 75%)
drawable-xhdpi/intro_text.png         (574 x 551 pixels - 112.5%)
  1. You can also specify a pre-scaling factor on the command line that is useful to create high-resolution phone images based solely on retina iPad images.

For example, if the iPad resources in your iOS project are 40% larger than the equivalent phone resources, you can specify a percentage on the command line when running the scripts to automatically create phone-sized images from just the iPad resources.

A directory containing the following files:

intro_text@2x~ipad.png    (1000 x 1000 pixels)

when processed with a 60% pre-scaling factor:

$ ios2android 0.60

will result in:

drawable-mdpi/intro_text.png          (300 x 300 pixels - 60% * 50%)
drawable-hdpi/intro_text.png          (450 x 450 pixels - 60% * 75%)
drawable-xhdpi/intro_text.png         (675 x 675 pixels - 60% * 112.5%)
drawable-xxhdpi/intro_text.png        (900 x 900 pixels - 60% * 150%)
drawable-large-mdpi/intro_text.png    (500 x 500 pixels - 50%)
drawable-large-hdpi/intro_text.png    (750 x 750 pixels - 75%)
drawable-large-xhdpi/intro_text.png   (1125 x 1125 pixels - 112.5%)

License

The MIT License (MIT)

Copyright (c) 2013 Ninjanetic Design Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Information

For more information on re-scaling iOS images to Android, you can find a great web tool here:

http://www.teehanlax.com/tools/density/

ios2android was created by Jason Adams of Ninjanetic Design Inc.

ios2android's People

Contributors

jlchoike-dl avatar jznadams avatar rafaeltoledo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ios2android's Issues

Filename cannot contain a space

Script works fine, except for files that contain a space in the name. Maybe not such a big issue as filenames for ios/android should not have spaces anyway. This is the error I get for the files with a space in the name:

./ios2android: line 79: [: status: binary operator expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.