Using commands for batch FLIF file conversions

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
benghson
Posts: 8
Joined: 2017-06-28T13:16:15-07:00
Authentication code: 1151

Using commands for batch FLIF file conversions

Post by benghson » 2017-07-01T01:10:57-07:00

Hi guys. I'm having trouble batch conversion. Theoretically, there should be no losses in FLIF conversions if compression is used with the flif.exe compiler parameters optimally, but using ImageMagick there is clearly loss in less than 100 generations. Is there any custom commands in ImageMagick that I can specifically use for conversions in FLIF files?

Example: flif.exe -e -v -o -k -E100 -N -Q100 -K -W RGB48_lossless.flif

Usage: convert ...

User avatar
fmw42
Posts: 22081
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Using commands for batch FLIF file conversions

Post by fmw42 » 2017-07-01T10:40:40-07:00

If ImageMagick supports reading or writing of flif, then it is not listed on the formats page at http://www.imagemagick.org/script/formats.php. I do not know if that is an oversight or it is not listed because it needs special software to handle it and an entry in the delegates.xml file.

benghson
Posts: 8
Joined: 2017-06-28T13:16:15-07:00
Authentication code: 1151

Re: Using commands for batch FLIF file conversions

Post by benghson » 2017-07-01T18:00:51-07:00

There is no support for all the features that FLIF brings, the way it is to use flif.exe as support to do what I'm looking for (lossless batch conversion with rotation at 90 and -90 degrees for each image). However, I would like to know what is happening when I do the native flif v0.3 executable conversion, and I do the "flif -i example.flif" command, the following message is displayed:

example.flif: FLIF image, 474x490, 8-bit RGB, interlaced
Contains metadata: XMP


But when I do the command "identify.exe example.flif" it only brings me the following information:

example-flif FLIF 0x0 8-bit sRGB 243233B 0.109u 0: 00.111

So I try to open this same file by IMDisplay and I can not, it appears all white. But if I only use ImageMagick to do the conversion with the command "convert file.png example.flif" and then "identify example.flif", the following information is given to me:

example.flif FLIF 474x490 474x490 + 0 + 0 8-bit sRGB 243500B 0.109u 0: 00.135

So, what is happening? Is the version of the native executable flif.exe different from the core dll of ImageMagick, and so ImageMagick can not read the file originally converted by flif.exe? What can I do to resolve this issue?

I've created a batch script code to make lossless batch conversions for flif files (as is done at https://www.youtube.com/watch?v=_h5gC3EzlJg) but the result is coming with lots of losses in less than 100 Generations. I would like to use flif.exe and ImageMagick convert since ImageMagick does not fully support FLIF, as in its help:

Usage:
   Flif [-e] [encode options] <input image (s)> <output.flif>
   Flif [-d] [decode options] <input.flif> <output.pnm | Output.pam | Output.png
>
Supported input / output image formats: PNG, PNM (PPM, PGM, PBM), PAM
General Options:
   -h, --help show help (use -hvv for advanced options)
   -v, --verbose increase verbosity (multiple -v for more output)
Encode options: (-e, --encode)
   -E, --effort = N 0 = fast / poor compression, 100 = slowest / best? Defau
Lt: -E60)
   -I, - interlacing interface (default, except for tiny images)
   -N, --no-interlace force in interlacing
   -Q, --lossy = N lossy compression; Default: -Q100 (lossless)
   -K, --keep-invisible-rgb store original RGB values ​​behind A = 0
   -F, --frame-delay = N [, N, ...] delay between animation frames in ms; Default: -F
100
Decode options: (-d, --decode)
   -i, --identify do not decode, just identify the input FLIF file
   -q, --quality = N lossy decode quality percentage; Default -q100
   -s, --scale = N lossy downscaled image at scale 1: N (2,4,8,16,32);
 Default -s1
   -r, --resize = WxH lossy downscaled image to fit inside WxH (but typi
Cally smaller)
   -f, --fit = WxH lossy downscaled image to exactly WxH

Well that way I could try converting with -E100 (theoretically the best compression even taking more time), which is not possible with the ImageMagick convert apparently ...

benghson
Posts: 8
Joined: 2017-06-28T13:16:15-07:00
Authentication code: 1151

Re: Using commands for batch FLIF file conversions

Post by benghson » 2017-07-01T18:01:50-07:00

Batch Script code:

convert original.png teste0.flif
echo off
setlocal enableDelayedExpansion
set /a "prox=0"
set /a x=0
for /L %%G in (0,1,1999) do (
set /a prox=%%G+1
set /a x=prox %% 2
set /a "q=!random! %% 40 +60"
if !x!==0 (
convert teste%%G.flif -rotate -90 -quality !q! teste!prox!.flif
echo teste%%G.flif / teste!prox!.flif // q: !q!
)
if !x!==1 (
convert teste%%G.flif -rotate 90 -quality !q! teste!prox!.flif
echo teste%%G.flif / teste!prox!.flif // q: !q!
)
)
echo on

benghson
Posts: 8
Joined: 2017-06-28T13:16:15-07:00
Authentication code: 1151

Re: Using commands for batch FLIF file conversions

Post by benghson » 2017-07-01T18:18:14-07:00

There is nothing in delegates.xml ... there is no .flif format reference despite formatting support.

User avatar
fmw42
Posts: 22081
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Using commands for batch FLIF file conversions

Post by fmw42 » 2017-07-01T18:32:25-07:00

But when I do the command "identify.exe example.flif" it only brings me the following information:

example-flif FLIF 0x0 8-bit sRGB 243233B 0.109u 0: 00.111
I suspect that ImageMagick does not support flif format and it is just producing some output of zero size (that is the field WxH=0x0). I am not sure why it does not give any warnings or error messages about flif not compatible.

Since I am not a developer, you will need to wait to hear back from one of them about support for flif format. In the mean time all you can do is use the flif commands directly outside ImageMagick.

benghson
Posts: 8
Joined: 2017-06-28T13:16:15-07:00
Authentication code: 1151

Re: Using commands for batch FLIF file conversions

Post by benghson » 2017-07-02T07:23:29-07:00

fmw42 wrote:
2017-07-01T18:32:25-07:00
But when I do the command "identify.exe example.flif" it only brings me the following information:

example-flif FLIF 0x0 8-bit sRGB 243233B 0.109u 0: 00.111
I suspect that ImageMagick does not support flif format and it is just producing some output of zero size (that is the field WxH=0x0). I am not sure why it does not give any warnings or error messages about flif not compatible.

Since I am not a developer, you will need to wait to hear back from one of them about support for flif format. In the mean time all you can do is use the flif commands directly outside ImageMagick.
Typing "flv -hvv" I was able to see the advanced options (which also shows me more commands). I'm going to do some testing and see if I can do anything to make the interaction between ImageMagick and Flif more compatible, like strip Exif / XMP metadata file.

General Options:
    -h, --help show help (use -hvv for advanced options)
    -v, --verbose increase verbosity (multiple -v for more output)
    -c, --no-crc do not verify the CRC (or do not add to CRC)
    -m, --no-metadata strip Exif / XMP metadata (default is to keep it)
    -p, --no-color-profile strip ICC color profile (default is to keep it)
    -o, --overwrite overwrite existing files
    -k, --keep-palette use input PNG palette / write palette PNG if poss
Ible

I'll post the result here.

benghson
Posts: 8
Joined: 2017-06-28T13:16:15-07:00
Authentication code: 1151

Re: Using commands for batch FLIF file conversions

Post by benghson » 2017-07-02T07:35:06-07:00

I discovered the problem. This is really the XMP metadata. When I removed using the command "flif -m original.png original.flif", the file was converted without the xmp metadata. That way, I was able to open the file normally in IMDisplay.exe. I'm going to do a few more tests and try running this batch to see if I can perform batch conversions.

Post Reply