Giter Site home page Giter Site logo

bulkimageresizer's Introduction

BulkImageResizer

BulkImageResizer automates image resizing and compression of any number of images in a folder. I developed this script to automatically resize and compress the images for responsive front end web development.

Getting Started

Followig instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

No prerequisites. BulkImageResizer is compatible with both Python2 and Python3.

Installation

  • Basic installation on your default Python version. Type in following code on your terminal:
$ pip install BulkImageResizer

If you want to install on a different Python version than default then:

  • if default is Python2, then to install on Python3:
$ python3 -m pip install BulkImageResizer
  • if default is Python3, then to install on Python2:
$ python2 -m pip install BulkImageResizer

Usage

  1. First import the module using the following command on your python project.
from BulkImageResizer.BulkImageResizer import BulkImageResizer
  1. Instantiate BulkImageResizer object with the following arguments:
  • path to source folder (containing images)
  • path to new folder (to save resized images). here is an example:
sourceFolder = '/Users/SK/Desktop/sourceFolder/'
exportFolder = '/Users/SK/Desktop/exportFolder/'

test1 = BulkImageResizer(sourceFolder, exportFolder)

3.1 To resize the image use imageResize() method. It takes minimum two integer numbers as arguments, which indicates the size you want in pixels. here is an example:

test1.imageResize(800, 600)

this will resize all the images in the sourceFolder according to given pixels and save them in exportFolder. The original photos in the sourceFolder will not change. If you want to keeps aspect ratio unchanged then use the following:

test1.imageResize(800, 600, aspectRatio=False)

this will resize all the images in the sourceFolder so that no matter what the length of the longer side of the image will equal 800px and the length of the shorter side of the image will be calculated based on the aspect ration of the original image. The resized images will be saved in exportFolder. You can also change the subsampling value and quality of the image. By default subsampling is set to 1 and can be changed from 0 up to 2. Quality is set to 95, which is the maximum quality and can be lowered if you would like to compress the image and decrease file size.

test1.imageResize(800, 600, subsampling=2, quality=85)

3.2 If you want to just comress the photo without changing the pixel size then you can use imageCompress() method. By default quality is set to 95. If you would like to decrease the file size then you can lower the quality.

test1.imageCompress(quality=75)

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Version

Current Version: 1.0.4. For the versions available, see the tags on this repository.

Authors

Suhrab Kurbanov - Initial work See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgements

Hat tip to anyone whose code was used

bulkimageresizer's People

Contributors

suhrabjan avatar

Watchers

James Cloos avatar  avatar

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.