LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-28-2018, 04:52 PM   #1
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1, Centos 7
Posts: 278

Rep: Reputation: 32
ImageMagick - Convert one liner


Hi Gurus,

Quick question. I have these two commands for cropping png images that are in the same dir. The first command is the conventional way of doing things and I understand it. But the format of the second command is something I have not seen before. What do the `[]' do? How do they work? Why isn't convert looking for files named "filename-1.png[715x455+605+355]","filename-2.png[715x455+605+355]" for example?


1: convert -crop 715x455+605+355 '*.png' +repage question-%02d.png
2: convert '*.png[715x455+605+355]' +repage question-%02d.png


Many thanks for any explanation.

BashTin.
 
Old 02-28-2018, 06:48 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
Quote:
Originally Posted by BashTin View Post
What do the `[]' do? How do they work? Why isn't convert looking for files named "filename-1.png[715x455+605+355]","filename-2.png[715x455+605+355]" for example?
There's a good explanation in the docs: https://www.imagemagick.org/Usage/files/#read_crop
 
3 members found this post helpful.
Old 03-01-2018, 03:14 AM   #3
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1, Centos 7
Posts: 278

Original Poster
Rep: Reputation: 32
Wink

Thanks for pointer norobro, RTFM

"The real purpose of these read modifiers is to limit the amount of memory needed, by removing unwanted images or making images smaller, while images are still being read into memory. For example when readin a whole directory of large JPEG images."

If I understand it correctly the second method, read modifiers, means ImageMagick takes the image does the crop/resize then puts the result in memory. The first way the image (full sized, original image) is loaded into memory first and then the crop/resize done. Is that about right?

Anyway for what I want both essentially do the same thing and I like the succinctness of the second command.

BashTin.
 
Old 03-01-2018, 03:31 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,066

Rep: Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594
Quote:
Originally Posted by BashTin View Post
... and I like the succinctness of the second command.
succinctness often gets in the way of understanding - even when I wrote it.

If you constantly use it, generally not a problem, but if you go away from it for 6-12 months ... ?. Sometimes the more obvious (aka less obtuse) construct makes sense. Maybe I'm just getting old ...
 
Old 03-01-2018, 04:34 AM   #5
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1, Centos 7
Posts: 278

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by syg00 View Post
succinctness often gets in the way of understanding - even when I wrote it.

If you constantly use it, generally not a problem, but if you go away from it for 6-12 months ... ?. Sometimes the more obvious (aka less obtuse) construct makes sense. Maybe I'm just getting old ...
Actually I thought the second way was less obtuse, but I am sure I am old
 
Old 03-01-2018, 08:24 AM   #6
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
Quote:
Originally Posted by BashTin View Post
Thanks for pointer norobro, RTFM
Sorry, I didn't mean to be curt. I was reading that page a couple of days ago and thought that pointing you to it would be much better than my trying to explain the command.

I am an oldster, too!

Last edited by norobro; 03-01-2018 at 12:19 PM. Reason: grammar - my in lieu of me
 
Old 03-01-2018, 09:33 AM   #7
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 14.1, Centos 7
Posts: 278

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by norobro View Post
Sorry, I didn't mean to be curt. I was reading that page a couple of days ago and thought that pointing you to it would be much better than me trying to explain the command.

I am an oldster, too!
You did not come across as curt. And I didn't mean my reply to come across as suggesting you were curt. It is just that you are told so many time to RTFM, first. And then, you quite rightly pointed me to the docs, so I just thought it was ironic as I hoped I would never be one who fell into RTFM trap.. In my defence I did read the man page but there was no info there about read modifiers (at that time I didn't even know what those were) and there is a load of online docs online at www.imagemagick.org but, as I am sure you will appreciate, unless you have a good idea what you are searching for you could read all day and not find the answer to your specific query.

I often wish those with more experience with Linux would take it easier on newbies. It is easy to go look at the manual WHEN you know about the manual/documentation and just as importantly what you are looking for and how to look for it.

So no offence taken, and thanks very much for your time and pointing me in the right direction.

Off to play Nethack now
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change a color in a png with imagemagick convert Jykke Linux - Software 2 10-08-2015 12:56 AM
ImageMagick convert and eps Daravon Linux - Software 7 02-16-2012 04:06 PM
[SOLVED] Using convert from imagemagick package to convert multiple jpg files janis_169 Linux - Newbie 5 07-18-2010 04:22 PM
ImageMagick - convert cornish Linux - Software 3 06-13-2006 08:26 AM
where would I find ImageMagick's convert program? kuplo Linux - Software 1 01-12-2006 12:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration