Skip to content

Commit 0a0f6ac

Browse files
committed
Link to C++ Cheat, split imagemagick.
1 parent 9a3f69a commit 0a0f6ac

File tree

3 files changed

+136
-124
lines changed

3 files changed

+136
-124
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ Other tools:
9797

9898
Related subjects in other repositories:
9999

100-
- [networking](https://github.com/cirosantilli/net): networking tools and protocols: HTTP, SSH, curl Apache.
100+
- [C++ Cheat](https://github.com/cirosantilli/cpp-cheat): contains some compilation / language heavy subjects like the POSIX C API or generation of dynamic libraries.
101+
- [Networking Cheat](https://github.com/cirosantilli/networking-tutorial): networking tools and protocols: HTTP, SSH, curl Apache.
101102

102103
##How to search for keywords
103104

image/README.md

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -172,129 +172,7 @@ And changing the width was not working for me:
172172

173173
#Utilities
174174

175-
##ImageMagick
176-
177-
Tons of image conversion tools.
178-
179-
CLI + APIs in lots of languages, including C (native), C++ and Python.
180-
181-
Reading the manual is a great image manipulation course.
182-
183-
###identify
184-
185-
Get info on ImageMagick on given image file and file formats supported by ImageMagick.
186-
187-
List supported formats:
188-
189-
identify -list format
190-
191-
Get size of an image:
192-
193-
identify -format "%[fx:w]x%[fx:h]" a.jpg
194-
195-
###convert
196-
197-
- process images
198-
- converts between formats
199-
- input/output format can be deduced automatically (from extension/magic)
200-
201-
Does not do:
202-
203-
- DJVU
204-
205-
####GIF operations
206-
207-
GIF to several images:
208-
209-
convert a.gif a.png
210-
211-
Generates `a-N.png` images.
212-
213-
Several images to GIF loop forever:
214-
215-
convert -delay 100 img*.png img.gif
216-
217-
or:
218-
219-
convert -delay 100 -loop 0 img*.png img.gif
220-
221-
Loop once and stop
222-
223-
convert -delay 100 -loop 1 img*.png img.gif
224-
225-
####resize
226-
227-
Resize to 50% or original size:
228-
229-
convert large.png -resize 50% small.png
230-
231-
This:
232-
233-
- takes averages between pixels to make image have less pixels
234-
- keeps bit depth
235-
236-
Therefore, the image file size will be just a bit more than 1/4 of the original because:
237-
238-
- 1/2 x 1/2 = 1/4 of the number of pixels
239-
- the PNG metadata size is unchanged, so this is not divided by 4.
240-
241-
Resize to fixed width of 100 px, height maintains original proportion:
242-
243-
convert large.png -resize 100x small.png
244-
245-
####crop
246-
247-
`10x10`: rectangle to keep:
248-
249-
convert -crop 10x10 a.jpg b.jpg
250-
251-
`+10+10`: top left corner of rectangle
252-
253-
convert -crop 10x10+10+10 a.jpg b.jpg
254-
255-
top 50 percent:
256-
257-
convert -crop 100x50% a.jpg b.jpg
258-
259-
cannot give top left corner in percentage
260-
261-
bottom 50 percent:
262-
263-
convert -gravity south -crop 100x50% a.jpg b.jpg
264-
265-
####color
266-
267-
- `-colorspace Gray`: convert to grayscale:
268-
269-
convert in.png -colorspace Gray out.png
270-
271-
- `-monochrome`: monochrome image. TODO == -depth 1? But not in my tests.
272-
273-
- `-depth`: number of bits per pixel.
274-
275-
- `-density`: PDFs are fixed width for printers, not pixel data, so you have to say how many DPI you want to take 300 makes output quite readable
276-
277-
Always set this for PDFs.
278-
279-
PDF to one JPG per page:
280-
281-
convert -density 300 a.pdf a.jpg
282-
283-
- `-threshold`: Simple way to convert to black and white: if color average is above threshold, pixel is white else pixel is black:
284-
285-
convert -threshold 50 a.jpg b.jpg
286-
287-
- `-level`: linear transform on color space:
288-
289-
convert -level -100,100 a.jpg b.jpg
290-
291-
###animate
292-
293-
Animate multiple images interactively:
294-
295-
animate -delay 100 img*.png
296-
297-
Not meant to generate a GIF from the command line, but good choice to preview a GIF before creating one.
175+
[ImageMagick](imagemagick.md)
298176

299177
##ExactImage
300178

image/imagemagick.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#ImageMagick
2+
3+
Tons of image conversion tools.
4+
5+
CLI + APIs in lots of languages, including C (native), C++ and Python.
6+
7+
Reading the manual is a great image manipulation course.
8+
9+
Man pages are very shallow: have a look at the online docs instead:
10+
11+
- <http://www.imagemagick.org/script/command-line-options.php>
12+
13+
##identify
14+
15+
Get info on ImageMagick on given image file and file formats supported by ImageMagick.
16+
17+
List supported formats:
18+
19+
identify -list format
20+
21+
Get size of an image:
22+
23+
identify -format "%[fx:w]x%[fx:h]" a.jpg
24+
25+
##convert
26+
27+
- process images
28+
- converts between formats
29+
- input/output format can be deduced automatically (from extension/magic)
30+
31+
Does not do:
32+
33+
- DJVU
34+
35+
###resize
36+
37+
Resize to 50% or original size:
38+
39+
convert large.png -resize 50% small.png
40+
41+
This:
42+
43+
- takes averages between pixels to make image have less pixels
44+
- keeps bit depth
45+
46+
Therefore, the image file size will be just a bit more than 1/4 of the original because:
47+
48+
- 1/2 x 1/2 = 1/4 of the number of pixels
49+
- the PNG metadata size is unchanged, so this is not divided by 4.
50+
51+
Resize to fixed width of 100 px, height maintains original proportion:
52+
53+
convert large.png -resize 100x small.png
54+
55+
###crop
56+
57+
`10x10`: rectangle to keep:
58+
59+
convert -crop 10x10 a.jpg b.jpg
60+
61+
`+10+10`: top left corner of rectangle
62+
63+
convert -crop 10x10+10+10 a.jpg b.jpg
64+
65+
Top 50 percent:
66+
67+
convert -crop 100x50% a.jpg b.jpg
68+
69+
Cannot give top left corner in percentage
70+
71+
Bottom 50 percent:
72+
73+
convert -gravity south -crop 100x50% a.jpg b.jpg
74+
75+
###color
76+
77+
- `-colorspace Gray`: convert to grayscale:
78+
79+
convert in.png -colorspace Gray out.png
80+
81+
- `-monochrome`: monochrome image. TODO == -depth 1? But not in my tests.
82+
83+
- `-depth`: number of bits per pixel.
84+
85+
- `-density`: PDFs are fixed width for printers, not pixel data, so you have to say how many DPI you want to take 300 makes output quite readable
86+
87+
Always set this for PDFs.
88+
89+
PDF to one JPG per page:
90+
91+
convert -density 300 a.pdf a.jpg
92+
93+
- `-threshold`: Simple way to convert to black and white: if color average is above threshold, pixel is white else pixel is black:
94+
95+
convert -threshold 50 a.jpg b.jpg
96+
97+
- `-level`: linear transform on color space:
98+
99+
convert -level -100,100 a.jpg b.jpg
100+
101+
###Transparency to white
102+
103+
<http://stackoverflow.com/questions/2322750/replace-transparency-in-png-images-with-white-background>
104+
105+
convert image.png -background white -alpha remove white.png
106+
107+
###GIF operations
108+
109+
GIF to several images:
110+
111+
convert a.gif a.png
112+
113+
Generates `a-N.png` images.
114+
115+
Several images to GIF loop forever:
116+
117+
convert -delay 100 img*.png img.gif
118+
119+
or:
120+
121+
convert -delay 100 -loop 0 img*.png img.gif
122+
123+
Loop once and stop
124+
125+
convert -delay 100 -loop 1 img*.png img.gif
126+
127+
##animate
128+
129+
Animate multiple images interactively:
130+
131+
animate -delay 100 img*.png
132+
133+
Not meant to generate a GIF from the command line, but good choice to preview a GIF before creating one.

0 commit comments

Comments
 (0)