ImageMagick v7 development

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

ImageMagick v7 development

Post by anthony »

The Future of Mogrify (as planned but not yet implemented)....

IMv7 mogrify will produce two solutions to this problem. And either may be used. Mogrify will then allow the use of 'Image List Operators' like -composite. and would even be able to "mogrify" GIF animation files!

The first solution is simple, and could possibly be back ported to IMv6. A -read {image} operator which will be interpreted as a secondary image to load, and not as a 'primary image' to be modified.

For example..

Code: Select all

   mogrify -read overlay.png -composite  {images_to_process}....
Which will composite the the overlay over each of the given images to process.

The second method is a new syntax. If Imv7 mogrify sees a '--' option on the command line it will treat the first part
as the options to use to process each image, while the images (and only images) are listed after that option.

Code: Select all

  mogrify  overlay.png -composite  -- {images_to_process}....
Further if two '--' options are present the first part will define 'pre-read' settings, while the second part processing options, and the third part the images to process.

Code: Select all

  mogrify  -define jpeg:size 200x200 -- -thumbnail 100x100 -- {images_to_process}...
Comments on either proposed method welcome.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem using for loop to round edges

Post by Bonzo »

Out of interest when piping? an output in V6 you have to add an extra - to the second part of code. How will this be acheived in V7, will the space between the - and operator be enough?

Example ( in this case the - is on its own but in other cases it could be before another operator ):

Code: Select all

$cmd = " -size 140x80 xc:none -fill grey -gravity NorthWest ".  
" -draw \"text 10,10 \"Copyright\" \" -gravity SouthEast ".  
" -draw \"text 5,15 \"Copyright\" \" miff:- | composite ".  
" -tile - $input14 ";  
exec("convert $cmd tiled_text.jpg"
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem using for loop to round edges

Post by anthony »

In -tile - the '-' is a option argument, Which for -tile is a explicit image read. Actually this is something I want to change in IMv7 as I prefer tile to just use (and remove) the last image on the current image list, that way you can set a in-memory image to use for tiling.

If - is not an argument, then IM will first look to see if it is an option. It isn't.

In that situation IM treats it as a 'implicit read' operation. That is it will think of it as being a filename argument to explicitly perform -read {arg} (NOTE that the explict -read option is a new operator option in IMv7, and can be used to make it clear what you are doing.

It also lets you read from a filename that happens to also match an otpion name. For example: -read -tile will explicitly read from a file named "-tile"

A image filename of "-" is equivalent to a "fd:0" coder operation. Standard input is opened, ALL images are read, and (in IMv6) the file descriptor (stdin) is closed! In IMv7 I want to be able to perform single image reads, and not have the standard input closed, so later you can read another image (or something else) from the standard input (or whatever) pipeline.

NOTE: recent bug fixes includes a bug fix for reading from another file descriptor, as such this now works (very advanced shell scripting) see BASH FAQ

Code: Select all

   convert rose: test_image.png     # create image
  exec 5<test_image.png             # get shell to open image on fd 5
  convert  fd:5  info:              # convert reads fd 5
  exec 5<&-                         # shell closes fd 5
  rm test_image.png                 # clean up test image
IMv7 script options can come from a file, pipeline, or file descriptor, in just the same way.
I designed its reading carefully, so if single image reads from pipes become possible
then you should be able to mix options and images in the same pipeline!

NOTE single image reads will only work for image file formats that have a defined end-of-data point.
That is streaming image files formats
MIFF does, PbmPlus does, but TXT image do not.

Actually TXT images can 'stream' but they do not have a defined end-of-data to the format :-(
The start of the next image is used to end the previous image. so can not be used, as it stands.

I would class a 'newline' or 'return' character as the end-of-data for a label: image
but perhaps a EOT character (Ctrl-D) would be better for this purpose!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply