How to add filename/demensions as caption like this?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
jessec116
Posts: 5
Joined: 2020-02-25T00:23:09-07:00
Authentication code: 1152

How to add filename/demensions as caption like this?

Post by jessec116 »

Hi,

Here is the thing. I'm using Windows 10, ImageMagick-7.0.9-Q16. And I have a problem about adding labels to the pictures.

I want to edit mine like this.
Image

How can i write the code in the right way? And I have many pictures like that. And i want every each of them could be like the example picture. Is there a way(code) to automatically generate all thumbs? And then merge all thumbs in one big file?

Example:
my original picture's filename is A.jpg
Resolution is 3470x5206
Original size is 2.66MB
Last edited by jessec116 on 2020-02-25T01:13:32-07:00, edited 2 times in total.

jessec116
Posts: 5
Joined: 2020-02-25T00:23:09-07:00
Authentication code: 1152

Re: How to add filename/demensions as caption like this?

Post by jessec116 »

I'm totally new to the IM. Thanks to all the experts first.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add filename/demensions as caption like this?

Post by snibgo »

I can't see your image. It seems to have no protocol, eg "http:" or "https:"
snibgo's IM pages: im.snibgo.com

jessec116
Posts: 5
Joined: 2020-02-25T00:23:09-07:00
Authentication code: 1152

Re: How to add filename/demensions as caption like this?

Post by jessec116 »

snibgo wrote:
2020-02-25T00:55:28-07:00
I can't see your image. It seems to have no protocol, eg "http:" or "https:"
How about now?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add filename/demensions as caption like this?

Post by snibgo »

Your URL is:
http://pic.images.ac.cn/image/5e54cd04ac3d7

I get:
500 Internal Server Error
snibgo's IM pages: im.snibgo.com

jessec116
Posts: 5
Joined: 2020-02-25T00:23:09-07:00
Authentication code: 1152

Re: How to add filename/demensions as caption like this?

Post by jessec116 »

snibgo wrote:
2020-02-25T02:29:24-07:00
Your URL is:
http://pic.images.ac.cn/image/5e54cd04ac3d7

I get:
500 Internal Server Error
Image
What about now?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add filename/demensions as caption like this?

Post by snibgo »

Okay, I can see that. If you simply want to append text to the bottom of your image:

Code: Select all

magick toes.png ^
  ( +clone ^
    -fill #0af -colorize 100 ^
    -fill Black -gravity North -pointsize 25 ^
    -annotate 0 "Hello world\nanother line\nthird line" ^
    -trim ^
  ) ^
  -background #0af -append +repage ^
  out.png
Image
I chose a light blue background, "#0af". You could use white or whatever.
snibgo's IM pages: im.snibgo.com

jessec116
Posts: 5
Joined: 2020-02-25T00:23:09-07:00
Authentication code: 1152

Re: How to add filename/demensions as caption like this?

Post by jessec116 »

snibgo wrote:
2020-02-25T03:45:56-07:00
Okay, I can see that. If you simply want to append text to the bottom of your image:

Code: Select all

magick toes.png ^
  ( +clone ^
    -fill #0af -colorize 100 ^
    -fill Black -gravity North -pointsize 25 ^
    -annotate 0 "Hello world\nanother line\nthird line" ^
    -trim ^
  ) ^
  -background #0af -append +repage ^
  out.png
Image
I chose a light blue background, "#0af". You could use white or whatever.
Thanks but if i want to add filename(including suffix) & dimensions(orignal resolution/size, before any resizes and display with MBs) to the bottom of my image, what can i do? I know a little about %f, %G, %b etc. But I cant really get how to write them correctly.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add filename/demensions as caption like this?

Post by snibgo »

Escapes %w %h and so on are listed at https://www.imagemagick.org/script/escape.php

Just insert them within the annotation string, wherever you want them, eg:

Code: Select all

-annotate 0 "Hello %f world\nanother line %w x %h\nthird line"
Note that "\n" means a new line.

If you do this in a BAT script, double the percent signs: %%.
snibgo's IM pages: im.snibgo.com

Locked