diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/blog/2022-09-10-netbooks/darkstar.jpg | bin | 3578876 -> 155458 bytes | |||
| -rw-r--r-- | src/blog/2022-09-10-netbooks/final.jpg | bin | 6089913 -> 224546 bytes | |||
| -rw-r--r-- | src/blog/2022-09-10-netbooks/hd.jpg | bin | 5031032 -> 197080 bytes | |||
| -rw-r--r-- | src/blog/2022-09-10-netbooks/scramble.jpg | bin | 4134845 -> 206364 bytes | |||
| -rw-r--r-- | src/blog/2022-12-30-blog-ready/pc-planner.jpg | bin | 6497789 -> 203907 bytes | |||
| -rw-r--r-- | src/blog/2023-01-28-windows-desktop/settings.png | bin | 43045 -> 69520 bytes | |||
| -rw-r--r-- | src/blog/2023-01-28-windows-desktop/tiling.png | bin | 68884 -> 27650 bytes | |||
| -rw-r--r-- | src/blog/2023-02-25-job-control/jobs-diagram.png | bin | 56672 -> 37996 bytes | |||
| -rw-r--r-- | src/blog/2023-03-06-resize-pictures/resize-pictures.md | 86 | ||||
| -rw-r--r-- | src/blog/blog.md | 1 | ||||
| -rw-r--r-- | src/blog/feed.xml | 7 | ||||
| -rw-r--r-- | src/favicon.png | bin | 8829 -> 4828 bytes | |||
| -rw-r--r-- | src/me.png | bin | 223247 -> 226377 bytes | |||
| -rw-r--r-- | src/speedcubing/cubing.png | bin | 813446 -> 721767 bytes |
14 files changed, 94 insertions, 0 deletions
diff --git a/src/blog/2022-09-10-netbooks/darkstar.jpg b/src/blog/2022-09-10-netbooks/darkstar.jpg index 3d32dd1..fb736dd 100644 --- a/src/blog/2022-09-10-netbooks/darkstar.jpg +++ b/src/blog/2022-09-10-netbooks/darkstar.jpg | |||
| Binary files differ | |||
diff --git a/src/blog/2022-09-10-netbooks/final.jpg b/src/blog/2022-09-10-netbooks/final.jpg index 63b33bf..7789e14 100644 --- a/src/blog/2022-09-10-netbooks/final.jpg +++ b/src/blog/2022-09-10-netbooks/final.jpg | |||
| Binary files differ | |||
diff --git a/src/blog/2022-09-10-netbooks/hd.jpg b/src/blog/2022-09-10-netbooks/hd.jpg index 525726b..dcc84b5 100644 --- a/src/blog/2022-09-10-netbooks/hd.jpg +++ b/src/blog/2022-09-10-netbooks/hd.jpg | |||
| Binary files differ | |||
diff --git a/src/blog/2022-09-10-netbooks/scramble.jpg b/src/blog/2022-09-10-netbooks/scramble.jpg index 0d9cb5f..e9c6017 100644 --- a/src/blog/2022-09-10-netbooks/scramble.jpg +++ b/src/blog/2022-09-10-netbooks/scramble.jpg | |||
| Binary files differ | |||
diff --git a/src/blog/2022-12-30-blog-ready/pc-planner.jpg b/src/blog/2022-12-30-blog-ready/pc-planner.jpg index 8fb52e5..dc7d803 100644 --- a/src/blog/2022-12-30-blog-ready/pc-planner.jpg +++ b/src/blog/2022-12-30-blog-ready/pc-planner.jpg | |||
| Binary files differ | |||
diff --git a/src/blog/2023-01-28-windows-desktop/settings.png b/src/blog/2023-01-28-windows-desktop/settings.png index 85ec492..84bd2c2 100644 --- a/src/blog/2023-01-28-windows-desktop/settings.png +++ b/src/blog/2023-01-28-windows-desktop/settings.png | |||
| Binary files differ | |||
diff --git a/src/blog/2023-01-28-windows-desktop/tiling.png b/src/blog/2023-01-28-windows-desktop/tiling.png index dd1f3ec..ef28431 100644 --- a/src/blog/2023-01-28-windows-desktop/tiling.png +++ b/src/blog/2023-01-28-windows-desktop/tiling.png | |||
| Binary files differ | |||
diff --git a/src/blog/2023-02-25-job-control/jobs-diagram.png b/src/blog/2023-02-25-job-control/jobs-diagram.png index 484e7b9..d61a769 100644 --- a/src/blog/2023-02-25-job-control/jobs-diagram.png +++ b/src/blog/2023-02-25-job-control/jobs-diagram.png | |||
| Binary files differ | |||
diff --git a/src/blog/2023-03-06-resize-pictures/resize-pictures.md b/src/blog/2023-03-06-resize-pictures/resize-pictures.md new file mode 100644 index 0000000..c28340f --- /dev/null +++ b/src/blog/2023-03-06-resize-pictures/resize-pictures.md | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | # Resizing my website's pictures with ImageMagick and find(1) | ||
| 2 | |||
| 3 | I have noticed that most of the pictures I have uploaded on this website | ||
| 4 | are incredibly large: | ||
| 5 | |||
| 6 | ``` | ||
| 7 | $ du -h -d 1 sebastiano.tronto.net | ||
| 8 | 42M sebastiano.tronto.net/gemini | ||
| 9 | 42M sebastiano.tronto.net/http | ||
| 10 | 42M sebastiano.tronto.net/src | ||
| 11 | 100M sebastiano.tronto.net/.git | ||
| 12 | 225M sebastiano.tronto.net | ||
| 13 | ``` | ||
| 14 | |||
| 15 | Stupid modern phones and their multi-megapixel cameras! | ||
| 16 | I definitely do not want my minimalist blog to waste your bandwidth, | ||
| 17 | I have to fix this. I could just go through all my pictures and resize | ||
| 18 | them with something like [gimp](https://www.gimp.org/) - there are like | ||
| 19 | 10 of them. But that's boring. Let's do it with the command line instead. | ||
| 20 | |||
| 21 | ## ImageMagick | ||
| 22 | |||
| 23 | The obvious question is: how do we even edit an image file | ||
| 24 | with the command line? Luckily, there is a tool for that: | ||
| 25 | [ImageMagick](https://imagemagick.org/). This piece of software | ||
| 26 | does a ton of things, and I do not use it very often. So I always | ||
| 27 | need to look up what I want to do. | ||
| 28 | |||
| 29 | One way to invoke ImageMagick is by calling the `convert` command, | ||
| 30 | which can take a | ||
| 31 | [`-resize`](https://imagemagick.org/script/command-line-options.php#resize) | ||
| 32 | option, followed by a | ||
| 33 | [`geometry`](https://imagemagick.org/script/command-line-processing.php#geometry) | ||
| 34 | argument. After checking the online manual, I understood that the | ||
| 35 | command I was looking for was: | ||
| 36 | |||
| 37 | ``` | ||
| 38 | $ convert picture.jpg -resize "750>" picture.jpg | ||
| 39 | ``` | ||
| 40 | |||
| 41 | which resizes `picture.jpg` by scaling it down to at most 750px width - | ||
| 42 | keeping the ratio between width and height, and leaving it untouched if it | ||
| 43 | is already smaller. The value 750 was chosen after a couple of attempts, | ||
| 44 | it seems a good compromise between quality and size. | ||
| 45 | |||
| 46 | And now I just have to do this for all the pictures. Of course, running | ||
| 47 | the same command 10 times with a different argument is out of question. | ||
| 48 | |||
| 49 | ## find(1) | ||
| 50 | |||
| 51 | *(No "man page reading club" this time, but don't | ||
| 52 | worry, the series will be back soon.)* | ||
| 53 | |||
| 54 | A standard UNIX command, [`find`](https://man.openbsd.org/find) allows | ||
| 55 | you to scan a folder for files with certain properties (for example, | ||
| 56 | a certain name pattern) and perform actions on them (for example, | ||
| 57 | running a command). The OpenBSD and GNU versions of find have some | ||
| 58 | differences, check your local manual page. The commands I use | ||
| 59 | here have been tested on the GNU version, but should be standard. | ||
| 60 | |||
| 61 | To look for file and simply print their name, we can use `-name`: | ||
| 62 | |||
| 63 | ``` | ||
| 64 | $ find src -name \*.jpg -or -name \*.png | ||
| 65 | src/me.png | ||
| 66 | src/favicon.png | ||
| 67 | src/speedcubing/cubing.png | ||
| 68 | src/blog/2023-01-28-windows-desktop/settings.png | ||
| 69 | src/blog/2023-01-28-windows-desktop/tiling.png | ||
| 70 | src/blog/2022-09-10-netbooks/darkstar.jpg | ||
| 71 | src/blog/2022-09-10-netbooks/final.jpg | ||
| 72 | src/blog/2022-09-10-netbooks/scramble.jpg | ||
| 73 | src/blog/2022-09-10-netbooks/hd.jpg | ||
| 74 | src/blog/2023-02-25-job-control/jobs-diagram.png | ||
| 75 | src/blog/2022-12-30-blog-ready/pc-planner.jpg | ||
| 76 | ``` | ||
| 77 | |||
| 78 | Now we can use `-exec` to run a command on each of these files, | ||
| 79 | using `{}` to refer to the file's name: | ||
| 80 | |||
| 81 | ``` | ||
| 82 | find src \( -name \*.jpg -or -name \*.png \) -exec convert {} -resize "750>" {} \; | ||
| 83 | ``` | ||
| 84 | |||
| 85 | We get a couple of warnings about grayscale images, but whatever. | ||
| 86 | This seems to have worked. | ||
diff --git a/src/blog/blog.md b/src/blog/blog.md index 8bd57ea..c74c703 100644 --- a/src/blog/blog.md +++ b/src/blog/blog.md | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | ## 2023 | 6 | ## 2023 |
| 7 | 7 | ||
| 8 | * 2023-03-06 [Resizing my website's pictures with ImageMagick and find(1)](2023-03-06-resize-pictures) | ||
| 8 | * 2023-02-25 [Job control: one shell is all you need](2023-02-25-job-control) | 9 | * 2023-02-25 [Job control: one shell is all you need](2023-02-25-job-control) |
| 9 | * 2023-01-28 [The year of the Windows desktop](2023-01-28-windows-desktop) | 10 | * 2023-01-28 [The year of the Windows desktop](2023-01-28-windows-desktop) |
| 10 | * 2023-01-11 [Aaron Swartz](2023-01-11-aaron-swartz) | 11 | * 2023-01-11 [Aaron Swartz](2023-01-11-aaron-swartz) |
diff --git a/src/blog/feed.xml b/src/blog/feed.xml index 88f547b..ab75982 100644 --- a/src/blog/feed.xml +++ b/src/blog/feed.xml | |||
| @@ -9,6 +9,13 @@ Thoughts about software, computers and whatever I feel like sharing | |||
| 9 | </description> | 9 | </description> |
| 10 | 10 | ||
| 11 | <item> | 11 | <item> |
| 12 | <title>Resizing my website's pictures with ImageMagick and find(1)</title> | ||
| 13 | <link>https://sebastiano.tronto.net/blog/2023-03-06-resize-pictures</link> | ||
| 14 | <description>Resizing my website's pictures with ImageMagick and find(1)</description> | ||
| 15 | <pubDate>2023-03-06</pubDate> | ||
| 16 | </item> | ||
| 17 | |||
| 18 | <item> | ||
| 12 | <title>Job control: one shell is all you need</title> | 19 | <title>Job control: one shell is all you need</title> |
| 13 | <link>https://sebastiano.tronto.net/blog/2023-02-25-job-control</link> | 20 | <link>https://sebastiano.tronto.net/blog/2023-02-25-job-control</link> |
| 14 | <description>Job control: one shell is all you need</description> | 21 | <description>Job control: one shell is all you need</description> |
diff --git a/src/favicon.png b/src/favicon.png index 8a6b202..fca1e66 100644 --- a/src/favicon.png +++ b/src/favicon.png | |||
| Binary files differ | |||
| Binary files differ | |||
diff --git a/src/speedcubing/cubing.png b/src/speedcubing/cubing.png index 2c188d8..7ee8943 100644 --- a/src/speedcubing/cubing.png +++ b/src/speedcubing/cubing.png | |||
| Binary files differ | |||
