Convert hdr image to non-hdr image

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?".
Post Reply
dkrikun0
Posts: 5
Joined: 2019-06-24T03:19:56-07:00
Authentication code: 1152

Convert hdr image to non-hdr image

Post by dkrikun0 »

Hi,

I would like to convert an HDR (i.e in NetPFM format) image to non-HDR image (i.e. NetPGM).
The conversion needs to be "viewer-friendly", that is the resulting image needs be contrast, without cutting off information etc.

How could I achieve this with ImageMagick 7.0.8 Q16, with HDRI?

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

Re: Convert hdr image to non-hdr image

Post by snibgo »

Does "-auto-level" do what you want? If not, please link to a sample input, and say what output you want.
snibgo's IM pages: im.snibgo.com
dkrikun0
Posts: 5
Joined: 2019-06-24T03:19:56-07:00
Authentication code: 1152

Re: Convert hdr image to non-hdr image

Post by dkrikun0 »

I've tried
`magick src.pfm -auto-level src.pgm`

Now both feh and sxiv say src.pgm is broken, is there something else?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert hdr image to non-hdr image

Post by snibgo »

Please link to a sample input.
snibgo's IM pages: im.snibgo.com
dkrikun0
Posts: 5
Joined: 2019-06-24T03:19:56-07:00
Authentication code: 1152

Re: Convert hdr image to non-hdr image

Post by dkrikun0 »

magick rose: rose.pfm
magick rose.pfm -auto-level rose.pgm
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert hdr image to non-hdr image

Post by snibgo »

It seems that IM is writing rose.pgm as 32 bits/channel. (Just one channel, of course.) Gimp can't read the result.

If we insert "-depth 16" before writing, Gimp can read it fine.

Does that help?
snibgo's IM pages: im.snibgo.com
dkrikun0
Posts: 5
Joined: 2019-06-24T03:19:56-07:00
Authentication code: 1152

Re: Convert hdr image to non-hdr image

Post by dkrikun0 »

Almost, had to use -depth 8, for feh/sxiv.
Do I still need -auto-level?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert hdr image to non-hdr image

Post by snibgo »

dkrikun0 wrote:The conversion needs to be "viewer-friendly", that is the resulting image needs be contrast, without cutting off information etc.
I don't really understand your question. Perhaps "-auto-level" does what you want.
snibgo's IM pages: im.snibgo.com
Post Reply