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