1IMGP(1) User Commands IMGP(1)
2
3
4
6 imgp - Resize, rotate JPEG and PNG images.
7
9 imgp [OPTIONS] [PATH [PATH ...]]
10
12 imgp is a multiprocessing command line image resizer and rotator for
13 JPEG and PNG images.
14
15 Features
16
17 * resize by percentage or resolution
18 * rotate clockwise by specified angle
19 * adaptive resize considering orientation
20 * brute force to a resolution
21 * optimize images to save more space
22 * limit processing by minimum image size
23 * convert PNG to JPEG
24 * erase exif metadata
25 * specify output JPEG image quality
26 * force smaller to larger resize
27 * process directories recursively
28 * overwrite source image option
29
30 Adaptive mode
31
32 - If the specified and image orientations are same [(H >= V and h > v)
33 or (H < V and h < v)], the image is resized with the longer specified
34 side as reference.
35 - In case of cross orientation [(H >= V and h <= v) or (H < V and h >=
36 v)], the image is resized with the shorter specified side as reference.
37 Same as non-adaptive.
38
39 For example, if an image has a resolution of 2048x1365 and is being
40 resized to 1366x768:
41 - In regular mode (default), output image resolution will be 1152x768
42 - In adaptive mode, output image resolution will be 1366x910
43
44 Operational notes
45
46 - Multiple files and directories can be specified as source. If PATH is
47 omitted, the current directory is processed.
48 - Output image names are appended with _IMGP if '--overwrite' option is
49 not used. By default _IMGP files are not processed. Doing so may lead
50 to potential race conditions when '--overwrite' option is used.
51 - PNG files with lower target hres/vres are not converted (even if
52 '--convert' is used). Run 'imgp --convert (*.png)' separately to con‐
53 vert those.
54 - Resize and rotate are lossy operations. For additional reductions in
55 size try '--optimize' and '--eraseexif' options.
56 - Option '--optimize' is slower, the encoder makes an extra pass over
57 the image in order to select optimal encoder settings.
58 - Progressive JPEG images are saved as progressive.
59
61 -h, --help
62 Show help text and exit.
63
64 -x, --res=res
65 Output resolution in HRESxVRES or percentage.
66
67 -o, --rotate=deg
68 Rotate clockwise by a specified angle (in degrees). Negative
69 inputs rotate anti-clockwise. Rotation by 0 degree is not
70 allowed.
71
72 -a, --adapt
73 Adapt to specified resolution considering the orientation of the
74 image. Disabled by default.
75
76 -c, --convert
77 Convert PNG images to JPEG to save on space. The output image is
78 saved with '.jpg' extension.
79
80 -e, --eraseexif
81 Erase EXIF metadata of JPEG images. Preserved by default.
82
83 -f, --force
84 Force to the exact specified resolution. Disabled by default.
85
86
87 -H, --hidden
88 Include hidden (dot) files. By default hidden files are skipped.
89 -i, --includeimgp Process _IMGP files. Risky due to potential
90 race conditions.
91
92 -k, --keep
93 Do not process if image hres or vres matches specified hres or
94 vres, or --res is 100. However, PNG images are converted to JPEG
95 if --convert option is specified and JPEG images are made pro‐
96 gressive is --progressive option is specified.
97
98 -n, --enlarge
99 Enlarge smaller images. By default smaller images are not scaled
100 if specified resolution is greater.
101
102 -N --nearest
103 Use nearest neighbour interpolation for PNG images instead of
104 default antialias.
105
106 -p, --optimize
107 Optimize output images using PIL library optimization algorithm.
108 Disabled by default.
109
110 -P, --progressive
111 Save all output JPEG images as progressive, even if the source
112 is not.
113
114 -q, --quality=N
115 Save the image with a specified quality factor N (scale 1-95,
116 default 75). JPEG only.
117
118 -m, --mute
119 Do not show any operational output.
120
121 -M, --minresres
122 minimum resolution in HxV or percentage of --res to resize
123
124 -r, --recurse
125 Recursively process sub-directories. By default only the speci‐
126 fied directory is processed. Symbolic links are ignored to avoid
127 recursive loops.
128
129 -s, --size=byte
130 Minimum size in bytes required to process an image. Acts as a
131 guard against processing low-resolution images. Default 1024
132 bytes.
133
134 -w, --overwrite
135 Overwrite the source images. By default an output image is saved
136 with _IMGP appended to the source image name.
137 NOTE: If overwrite and convert options are used together, source
138 PNG images are deleted.
139
140 -d, --debug
141 Enable debugging.
142
144 1. Convert some images and directories:
145
146 $ imgp -x 1366x768 ~/ ~/Pictures/image3.png ~/Downloads/
147 /home/testuser/image1.png
148 3840x2160 -> 1365x768
149 11104999 bytes -> 1486426 bytes
150
151 /home/testuser/image2.jpg
152 2048x1365 -> 1152x768
153 224642 bytes -> 31421 bytes
154
155 /home/testuser/Pictures/image3.png
156 1920x1080 -> 1365x768
157 2811155 bytes -> 1657474 bytes
158
159 /home/testuser/Downloads/image4
160 2048x1365 -> 1152x768
161 224642 bytes -> 31421 bytes
162
163 2. Scale an image by 75% and overwrite the source image:
164
165 $ imgp -x 75 -w ~/image.jpg
166 /home/testuser/image.jpg
167 1366x767 -> 1025x575
168 120968 bytes -> 45040 bytes
169
170 3. Rotate an image clockwise by 90 degrees:
171
172 $ imgp -o 90 ~/image.jpg
173 120968 bytes -> 72038 bytes
174
175 4. Adapt the images in the current directory to 1366x1000 resolution.
176 Visit all directories recursively, overwrite source images, ignore
177 images with matching hres or vres but convert PNG images to JPEG.
178
179 $ imgp -x 1366x1000 -wrack
180
181 5. Set hres=800 and adapt vres maintaining the ratio.
182
183 $ imgp -x 800x0
184 Source omitted. Processing current directory...
185
186 ./image1.jpg
187 1366x911 -> 800x534
188 69022 bytes -> 35123 bytes
189
190 ./image2.jpg
191 1050x1400 -> 800x1067
192 458092 bytes -> 78089 bytes
193
194 6. Process images greater than 50KiB only:
195
196 $ imgp -wrackx 1366x1000 -s 51200
197
198 7. Generate thumbnail of the last modified file in the current dir:
199
200 #!/usr/bin/env sh
201
202 thumb64 ()
203 {
204 pop=$(ls -1t | head -1)
205 imgp -acx 64x64 "$pop"
206 }
207
209 Arun Prakash Jana <engineerarun@gmail.com>
210
212 https://github.com/jarun/imgp
213
215 https://github.com/jarun/imgp/issues
216
218 Copyright © 2016-2020 Arun Prakash Jana <engineerarun@gmail.com>
219
220 License GPLv3+: GNU GPL version 3 or later
221 <http://gnu.org/licenses/gpl.html>.
222 This is free software: you are free to change and redistribute it.
223 There is NO WARRANTY, to the extent permitted by law.
224
225
226
227Version 2.8 01 Dec 2020 IMGP(1)