Issue
On a Plex server running on a Debian 11 I have around 100 albums with the wrong aspect ratio cover art. Plex saving the pictures in several subfolders with the name “com.plexapp.agents.localmedia_*”. I wanna edit all of them to be a square without moving their location.
How can I do it from the terminal to crop the pictures in with an aspect ratio of 1:1 without stretching the images or scaling them? I will do a backup in case the edit break the program.
From this and this I assume it would be something like this.
find . -name 'com.plexapp.agents.localmedia_*' -execdir convert -gravity center -crop_to_aspect_ratio 1:1 {} +
But I am getting the error:
convert-im6.q16: no images defined `./com.plexapp.agents.localmedia_d60dd557c42b03a3795a8d6888acc250f7cdbeec' @ error/convert.c/ConvertImageCommand/3229
The images are ca 800px max so the size is not causing the issue. Anyone did anything similar?
Edit: find . -name 'com.plexapp.agents.localmedia_*'
returns a list of the Album covers as following:
./f/90f4a8c26662a47b63c96f08428ac234984ccfb.bundle/Contents/_combined/posters/com.plexapp.agents.localmedia_6273d593da3e3f94e404622d39219443ff491fdc ./f/90f4a8c26662a47b63c96f08428ac234984ccfb.bundle/Uploads/posters/com.plexapp.agents.localmedia_6273d593da3e3f94e404622d39219443ff491fdc ./f/ac6989a8ff7a4c4dec6d97246c514f793a96626.bundle/Contents/_stored/posters/com.plexapp.agents.localmedia_13d13e34785396b31469331563de2fa298714e67 ./f/ac6989a8ff7a4c4dec6d97246c514f793a96626.bundle/Contents/_combined/posters/com.plexapp.agents.localmedia_13d13e34785396b31469331563de2fa298714e67 ./f/609cc7429f80bd3b06467f770a9723552c685ea.bundle/Contents/_combined/posters/com.plexapp.agents.localmedia_44c9c62fb4976dd078bba17be271cb2cdb76e71a ./f/609cc7429f80bd3b06467f770a9723552c685ea.bundle/Uploads/posters/com.plexapp.agents.localmedia_44c9c62fb4976dd078bba17be271cb2cdb76e71a
note that images have no extentions. this is checked again through the Files app through searching for 'com.plexapp.agents.localmedia_' and ensuring all results are pictures and all without extentins.
Solution
There are a few issues here:
If you use
convert
, you need to supply both an input filename and an output filename in the formatconvert INPUT -gravity ... -crop ... OUTPUT
. If you usemogrify
it modifies the file in place, so you only need a single filename. You appear to have usedconvert
with one filename which will not work.You are using
-execdir
rather than-exec
. I do not know why. The difference is thatexecdir
changes directory to the directory containing the file prior to running your command - this appears unnecessary in your case.
So, I think you need to use a command more like the following:
find . -type f -name "com.plexapp.agents.localmedia_*" -exec mogrify -gravity center -crop 1:1 {} \;
Or, if you really want to use convert
:
find . -type f -name "com.plexapp.agents.localmedia_*" -exec convert {} -gravity center -crop 1:1 {} \;
Answered By - Mark Setchell Answer Checked By - Marie Seifert (WPSolving Admin)