GithubHelp home page GithubHelp logo

weclaw1 / inbac Goto Github PK

View Code? Open in Web Editor NEW
322.0 4.0 37.0 17.23 MB

Python application for fast interactive image cropping

License: MIT License

Python 95.67% Dockerfile 3.93% Shell 0.40%
python3 image-manipulation cropping

inbac's Introduction

inbac

Donate

Description

inbac is an interactive batch cropper made for quick cropping of images.
I made this program because cropping thousands of images with image viewers or image manipulation programs was too slow.

Installation

The easiest way to use this application is to download the single file executable created with PyInstaller, which can be found on the releases page.

If you have python installed you can install with pip by typing:

pip install inbac

If you want to use the current master branch you can clone the repository and run the project using poetry.

Development Requirements

After installing above dependencies run poetry install in project directory to install remaining dependencies.

Examples

poetry run inbac /home/user/pictures/
Opens images in /home/user/pictures/ and saves cropped images to /home/user/pictures/crops

poetry run inbac -a 1 1 -r 256 256 /home/user/pictures/ /home/user/crops/
Opens images in /home/user/pictures/ in 1:1 ratio selection mode and saves images resized to 256x256px in /home/user/crops/

Usage

usage: inbac [-h] [-a ASPECT_RATIO ASPECT_RATIO] [-r RESIZE RESIZE]
             [-s SELECTION_BOX_COLOR] [-w WINDOW_SIZE WINDOW_SIZE]
             [-f IMAGE_FORMAT] [-q IMAGE_QUALITY]
             [input_dir] [output_dir]

inbac - interactive batch cropper

Left Mouse Button                 - select part of image

Z                                 - save selection and go to the next picture

X                                 - save selection and stay on the same picture

C                                 - rotate current image by 90 degrees

Hold Left Shift or Left Ctrl      - drag selection

Right Arrow or Right Mouse Button - go to next picture

Left Arrow or Middle Mouse Button - go to previous picture

positional arguments:
  input_dir             input directory (defaults to current working
                        directory)
  output_dir            output directory (defaults to folder crops in input
                        directory)

optional arguments:
  -h, --help            show this help message and exit
  -a ASPECT_RATIO ASPECT_RATIO, --aspect_ratio ASPECT_RATIO ASPECT_RATIO
                        selection should have specified aspect ratio
  -r RESIZE RESIZE, --resize RESIZE RESIZE
                        cropped image will be resized to specified width and
                        height
  -s SELECTION_BOX_COLOR, --selection_box_color SELECTION_BOX_COLOR
                        color of the selection box (default is black)
  -w WINDOW_SIZE WINDOW_SIZE, --window_size WINDOW_SIZE WINDOW_SIZE
                        initial window size (default is 800x600)
  -f IMAGE_FORMAT, --image_format IMAGE_FORMAT
                        define the croped image format
  -q IMAGE_QUALITY, --image_quality IMAGE_QUALITY
                        define the croped image quality

inbac's People

Contributors

ainasg avatar bryanjacobs avatar numeropi avatar ruancmoral avatar weclaw1 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

inbac's Issues

Multiple crops on same image saves only the last crop when specifying output format

Hello Robert Węcławski, thank you for this amazing program.
It is the best image crop tool that I found.

I hope you will have a few minutes to fix this minor detail.
It has no critical impact on the usage.

Suppose we make multiple crops on the same original file : image.png.
Running inbac without format option gives the correct result: image1.png, image2.png, image3.png, ...
Running inbac with format option (inbac -f png) gives only one output, despite the multiple crop: image, a PNG file in the correct format but without the extension .png

Perhaps the cause lies in controller.py -> save and/or find_available_name
Maybe we can fix it like this:
controller.py -> save line 161

    if self.model.args.image_format:
        new_filename, _ = os.path.splitext(new_filename)
        new_filename = os.path.join(new_filename, self.model.args.image_format) 

Anyway, thank you for your attention and for sharing this application.

Add menu

Add menu to let users set settings currently available only as command line arguments.

Add ability to rotate the image

Rotating the image is something that would be useful to me, because some images I crop are upside down. Pressing c will rotate the image by 90 degree.

Add error message when you use wrong path

When I run the application with not existing directory, app just pop out, exit and send exception to terminal

Traceback:

  File "<string>", line 1, in <module>
  File "/home/jarek/Downloads/Archives/inbac-master/inbac/inbac.py", line 34, in main
    app = Application(args.parse_arguments(), master=root)
  File "/home/jarek/Downloads/Archives/inbac-master/inbac/inbac.py", line 24, in __init__
    os.makedirs(args.output_dir)
  File "/usr/lib/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "/usr/lib/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "/usr/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/user'

In another case application just created directory and do nothing.

How reproduce this?

  • Run application with path where you doesn't have permission to create directories
  • Run application with path to folder which doesn't exist but in path where you have permission to create

Crop to clipboard & small crop size

Hi !
First, thank you for this very useful tool. It helped me a lot for a job.
When I was using it, I had some feature ideas that could further improve this tool.

For my job, I need to individually analyze and, if necessary, crop, copy and paste into a single Word document a lot of pictures (500 to 1700 for each task). Here are my ideas :

  1. An option to add cropped image to clipboard instead of saving it

I managed to do something similar using a very basic batch script in the "crops" folder with a loop saving new files to clipboard using nircmd from NirSoft, it saved me a lot of time :
@echo off
:loop
FOR /F "delims=" %%I IN ('DIR "*.*" /A-D /B /O:D') DO SET "Last=%%I"
"**nircmd directory**\nircmd.exe" clipboard copyimage "%Last%"
goto :loop
stop

  1. Along with a copy option, a way to copy the whole picture if no cropping is necessary.
  2. A way to jump to a specific image (i.e. image 145/312) without having to scroll through all images.
  3. An option to prevent inbac from resizing images to a specific size if they are smaller (didn't try much, but if I'm correct setting a size like 1280x720 will upscale a 640x360 picture).
  4. As you described in #17

Thank you again for your incredible tool ! It made my job a bit faster and easier.

Add about dialog

Add about dialog with program description and current version

Add settings dialog

Add settings dialog to menu to let user set settings currently available as command line arguments.

Linux install package fail becaus of font problem

Hi
When trying to run the file in linux package (inbac-Linux.zip in releases), I get warnings and error message, complaining about fonts:

[seb@surface3 Téléchargements]$ ./inbac
Fontconfig warning: "/etc/fonts/fonts.conf", line 5: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-sub-pixel-rgb.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-yes-antialias.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/48-spacing.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 4: unknown element "description"
Traceback (most recent call last):
File "inbac/inbac.py", line 40, in
File "inbac/inbac.py", line 34, in main
File "inbac/inbac.py", line 16, in init
File "inbac/view.py", line 22, in init
File "inbac/view.py", line 44, in create_menu
File "tkinter/init.py", line 3272, in init
File "tkinter/init.py", line 2567, in init
_tkinter.TclError: failed to allocate font due to internal system font engine problem
[5695] Failed to execute script inbac

Implement drag selection

Holding Shift or CTRL and moving mouse with pressed left mouse button should move the selection.

Add parameters to set saved images format and quality

Currently images are saved in the same format as they were when they were opened. In case of PNG files they won't lose quality, but in case of JPEG images they will be saved with Pillow default, which is 75 out of 100.

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.