Search | Sailfish OS | Running | PineTime | All Posts

Rotating photos through CLI with FreeBSD

October 30, 2023 — Nico Cartron

Continuing with my laptop migration to FreeBSD...

The need

Some of the thumbnails images I generate for this blog have not a correct orientation - as in: portrait instead of landscape.

I'm sure this is because of the script I wrote, which leverages mogrify, but I don't have time to fix it now, so I preferred spending time on finding a way to easily rotate photos.

The way I was doing it on MacOS is by using the "rotate picture" feature of the Finder, however the file browser I'm using, XFCE's Thunar, does not have such a feature.

The solution

A quick search returned a very simple and efficient way to do this with FreeBSD: use convert(1).

You just need to specify how much degrees you want, e.g.:

convert pica.jpg -rotate 90 pica.jpg

The nice thing with the above command is that you can rotate and save the new picture with a single command.

Testing it

Here's a pica I need to rotate:

By tapping that command:

convert 062023_convert-1.jpg -rotate 90 062023_convert-1-1.jpg

I end up having this:

As you can see, the rotation is clockwise, meaning that had the original picture been in the other direction, I would have use 270 degrees instead of 90.

Wrap Up

OK, convert does the job and I'm happy it's easy to do.

However I'll need to spend some time to figure out why some pictures have a wrong orientation - I'm sure it's nothing and can easily be fixed.
Stay tuned!

Tags: FreeBSD, Tips

I don't have any commenting system, but email me (nicolas at ncartron dot org) your comments!
If you like my work, you can buy me a coffee!