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 re‐
40 sized 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 in‐
69 puts rotate anti-clockwise. Rotation by 0 degree is not allowed.
70
71 -a, --adapt
72 Adapt to specified resolution considering the orientation of the
73 image. Disabled by default.
74
75 -c, --convert
76 Convert PNG images to JPEG to save on space. The output image is
77 saved with '.jpg' extension.
78
79 -e, --eraseexif
80 Erase EXIF metadata of JPEG images. Preserved by default.
81
82 -f, --force
83 Force to the exact specified resolution. Disabled by default.
84
85
86 -H, --hidden
87 Include hidden (dot) files. By default hidden files are skipped.
88 -i, --includeimgp Process _IMGP files. Risky due to potential
89 race conditions.
90
91 -k, --keep
92 Do not process if image hres or vres matches specified hres or
93 vres, or --res is 100. However, PNG images are converted to JPEG
94 if --convert option is specified and JPEG images are made pro‐
95 gressive is --progressive option is specified.
96
97 -n, --enlarge
98 Enlarge smaller images. By default smaller images are not scaled
99 if specified resolution is greater.
100
101 -N --nearest
102 Use nearest neighbour interpolation for PNG images instead of
103 default antialias.
104
105 -p, --optimize
106 Optimize output images using PIL library optimization algorithm.
107 Disabled by default.
108
109 -P, --progressive
110 Save all output JPEG images as progressive, even if the source
111 is not.
112
113 -q, --quality=N
114 Save the image with a specified quality factor N (scale 1-95,
115 default 75). JPEG only.
116
117 -m, --mute
118 Do not show any operational output.
119
120 -M, --minresres
121 minimum resolution in HxV or percentage of --res to resize
122
123 -r, --recurse
124 Recursively process sub-directories. By default only the speci‐
125 fied directory is processed. Symbolic links are ignored to avoid
126 recursive loops.
127
128 -s, --size=byte
129 Minimum size in bytes required to process an image. Acts as a
130 guard against processing low-resolution images. Default 1024
131 bytes.
132
133 -w, --overwrite
134 Overwrite the source images. By default an output image is saved
135 with _IMGP appended to the source image name.
136 NOTE: If overwrite and convert options are used together, source
137 PNG images are deleted.
138
139 -d, --debug
140 Enable debugging.
141
143 1. Convert some images and directories:
144
145 $ imgp -x 1366x768 ~/ ~/Pictures/image3.png ~/Downloads/
146 /home/testuser/image1.png
147 3840x2160 -> 1365x768
148 11104999 bytes -> 1486426 bytes
149
150 /home/testuser/image2.jpg
151 2048x1365 -> 1152x768
152 224642 bytes -> 31421 bytes
153
154 /home/testuser/Pictures/image3.png
155 1920x1080 -> 1365x768
156 2811155 bytes -> 1657474 bytes
157
158 /home/testuser/Downloads/image4
159 2048x1365 -> 1152x768
160 224642 bytes -> 31421 bytes
161
162 2. Scale an image by 75% and overwrite the source image:
163
164 $ imgp -x 75 -w ~/image.jpg
165 /home/testuser/image.jpg
166 1366x767 -> 1025x575
167 120968 bytes -> 45040 bytes
168
169 3. Rotate an image clockwise by 90 degrees:
170
171 $ imgp -o 90 ~/image.jpg
172 120968 bytes -> 72038 bytes
173
174 4. Adapt the images in the current directory to 1366x1000 resolution.
175 Visit all directories recursively, overwrite source images, ignore
176 images with matching hres or vres but convert PNG images to JPEG.
177
178 $ imgp -x 1366x1000 -wrack
179
180 5. Set hres=800 and adapt vres maintaining the ratio.
181
182 $ imgp -x 800x0
183 Source omitted. Processing current directory...
184
185 ./image1.jpg
186 1366x911 -> 800x534
187 69022 bytes -> 35123 bytes
188
189 ./image2.jpg
190 1050x1400 -> 800x1067
191 458092 bytes -> 78089 bytes
192
193 6. Process images greater than 50KiB only:
194
195 $ imgp -wrackx 1366x1000 -s 51200
196
197 7. Generate a 64px adaptive thumbnail of the last modified file in the
198 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-2023 Arun Prakash Jana <engineerarun@gmail.com>
219
220 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/li‐
221 censes/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.9 10 Sep 2023 IMGP(1)