Thumbnail image from DNG file is inappropriate using imagemagick or exif tool - imagemagick

I have a DNG image and a cropped monochromatic version of the image. Both are generating the same file as the thumbnail when I run any of the below commands:
magick.exe C:\sample1crop.dng -resize 500x375 C:\crop-T.JPG
or
magick.exe dng:C:\sample1crop.dng -intent relative -sample 500x375> -strip -auto-orient -density 72 C:\crop-T.JPG
or
magick.exe convert dng:C:\sample1original.dng -thumbnail 500x375 -filter -auto-orient -density 72 C:\orig-T.JPG
As I am not allowed to upload the DNG files, thus I uploaded the images in hightail, sharing the link below: https://spaces.hightail.com/space/ThDEDYZVey
The generated thumbnail for both the cases:
I tried to get the thumbnail with exiftool as well:
exiftool -b -PreviewImage C:\86854\SLS\Issues\ART-73712\crop-T.JPG > C:\86854\SLS\Issues\ART-73712\thumbnail.jpg
exiftool -b -ThumbnailImage C:\86854\SLS\Issues\ART-73712\crop-T.JPG > C:\86854\SLS\Issues\ART-73712\thumbnail.jpg
but the resulting file seems corrupted. When I extract the exiftool metadata I see:
"ThumbnailTIFF": "(Binary data 42194 bytes, use -b option to extract)"
My requirement here is to get a generic cmd that provides a cropped monochromatic thumbnail similar to the original image.

Using this exiftool command, I was able to extract four images from those files.
You don't mention what OS or shell you're using but if you're using Windows PowerShell, it is known to corrupt binary data when piping or redirecting. Use CMD and you should be able to extract the images properly.

Related

convert Kodak png images into webP with sampling factor

I am trying to convert png images into webP with sampling factor. I am imagemagick tool for conversion, as they mentioned in docs -quality is used for sampling but it did not work.
This command works fine to covert kodak png to JPEG.
convert test/images/kodim$i.png -quality $(($j*5)) -sampling-factor 4:2:0 test/jpeg/kodim$i/`printf "%02d" $j`.jpg
Converting PnG to WebP
convert test/images/kodim$i.png -quality $(($j*5)) test/webP/kodim$i/`printf "%02d" $j`.webp
I want to follow same sampling as mentioned in JPEG.
This work fine on kodak images.
Just install webP encoder
sudo apt-get install webp
Code
for i in {01..24..1}; do
echo WebP Encoding test/images/kodim$i.png
mkdir -p test/webP/kodim$i
for j in {0..20..1}; do
cwebp test/images/kodim$i.png -q $(($j*5)) -o test/webP/kodim$i/`printf "%02d" $j`.webp
done
done
Important
This command creates a WebP lossy image at different qualities.
WebP lossy is always with YUV420 sampling, equivalent to imagemagick's -sampling-factor 2x2 (also -sampling-factor 4:2:0) for jpeg.

ffmpeg resize large image and high resolution

I tried to resize a very big image (457 MB and 21600x21600) with the following command
-i test.png -vf scale=320:-1 out.png
but it throws exception saying "Picture size 21600x21600 is invalid". How can I find out the biggest supported resolution by ffmpeg? Is there a way to resize this high resolution image with ffmpeg?
If you want to use ImageMagick it is included in most Linux distros and is available for macOS and Windows.
Your command becomes:
convert test.png -resize 320x result.png
If you are running v7 or newer, use:
magick test.png -resize 320x result.png
If you have lots to do, and you want all the resized images written in a directory called thumbs you can use:
mkdir thumbs
magick mogrify -path thumbs -resize 320x *.png
Alternatively, you may find vips is a lighter-weight installation and does a faster conversion using less memory:
mkdir thumbs
vipsthumbnail -s 320 -o "thumbs/%s.png" image.png

Paperclip, ImageMagick "UnrecognizedAlphaChannelType `remove'"

I am running a project with these software versions:
Paperclip 4.2.0
Rails 4.0.4
RHEL 6
convert -version => ImageMagick 6.8.9-9
convert -list configure =>
DELEGATES bzlib mpeg freetype jng jpeg lcms png ps tiff x zlib
and am getting this error while processing images through Paperclip.
Command :: convert '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g.jpg' -auto-orient -resize "x85" -crop "85x85+21+0" +repage -alpha remove -strip '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g20141205-17371-1ym7alo.png'
convert: UnrecognizedAlphaChannelType `remove' # convert.c/ConvertImageCommand/636.
Cocaine::ExitStatusError: Command 'convert '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g.jpg' -auto-orient -resize "x85" -crop "85x85+21+0" +repage -alpha remove -strip '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g20141205-17371-1ym7alo.png'' returned 1. Expected 0
Here is the command output:
from /home/proj/.rvm/gems/ruby-2.1.1/gems/cocaine-0.5.4/lib/cocaine/command_line.rb:96:in `run'
This error is caught on the Thumbnail processor in the make method.
The most confusing part of this is that I set a debugger when this error is caught, copied the src tmpfile to a permanent location outside my project and ran the exact same convert command as above and it runs successfully with exit status 0.
My next step in debugging would probably to bundle open cocaine, but I think there is something higher level going wrong... Hoping someone has run into this before?
I don't get the same problem on OSX.
You may have multiple installations of ImageMagick installed. You can check at the command line like so:
$ which -a convert
If you do have multiple installations, and Paperclip is referencing the "wrong" one, Paperclip allows you to specify the path to seek. As from the Paperclip README:
In development mode, you might add this line to config/environments/development.rb:
Paperclip.options[:command_path] = "/usr/local/bin/"

.CDR to .SVG Convert Using ImageMagick

I am on CentOS 6.4 and trying to convert .CDR to .SVG Convert Using ImageMagick using SSH command.
my 1.cdr file is in /var/www/vhosts/website.com/httpdocs/test/1.cdr
once converted to SVG it should be created in the same folder
Tried the following command:
convert /var/www/vhosts/website.com/httpdocs/test/1.cdr image.svg
The Error I am getting is:
sh: mplayer: command not found convert: Delegate failed "mplayer"
"%i" -really-quiet -ao null -vo png:z=3' #
delegate.c/InvokeDelegate/1032. convert: missing an image filename
image.svg' # convert.c/ConvertImageCommand/2800.
Not sure what does that mean ?
In order to convert CDR files you need to install uniconvertor for CDR delegate.
List of all delegates:
convert -list delegate
By default it outputs:
cdr => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
Install uniconvertor. For example, on Ubuntu it’s:
sudo apt-get install python-uniconvertor
Then run:
convert image.cdr -flatten -thumbnail '512x512' image.png
Or, with zoom cropping:
convert image.cdr -flatten -thumbnail '512x512^' -gravity center -crop 512x512+0+0 +repage image.png
And you’re done.
I convert to PNG here but you may use your own output format.
python-uniconvertor is part of inkscape.
It does not exist by itself.
Ubuntu/Mint recently removed all the old Python stuff, for Corel Draw I have to fire up the WinXP VM & Corel and export something Linux understands, usually PNG, a favourite
CDR & WMF files are pretty much dead to Linux, ImageMagick can still handle WMF though.

Converting JPEG colorspace (Adobe RGB to sRGB) on Linux

I am generating thumbnails and medium sized images from large photos. These smaller photos are for display in an online gallery. Many of the photographers are submitting JPEG images using Adobe RGB. I have been asked if the thumbnail and medium size images can use sRGB as the images as is appear "flat" in some browsers.
I'm currently using ImageMagick to create the smaller versions. It has a -colorspace option, but that doesn't seem to do what I want.
Is there any other way to do this? Also, do you think this is worthwhile?
You can use the ImageMagic -profile option:
convert image.jpg -profile <adobe.icc> -profile <sRGB.icc> new_image.jpg
See here for more details:
http://www.imagemagick.org/Usage/formats/#color_profile.
Have you tried using Little CMS? This command will convert an image with a special color profile (i.e. Adobe RGB 1998) to one with no color profile but the same effective colors:
jpgicc -q100 input.jpg output.jpg
I'm setting JPEG quality to 100 here.
The following thread in the ImageMagick forum discusses exactly this in some detail: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16464
I now use this bash script to convert any picture (including CMYK) to sRGB:
http://alma.ch/scripts/any2srgb
It requires icc profiles for images which don't have embedded profiles. These can be found easily on the web. For example on Adobe's site: http://www.adobe.com/cfusion/search/index.cfm?term=icc+profile&siteSection=support%3Adownloads
Here is a summary (untested) of what the full script does (without it's resize and other options). It requires profiles and ImageMagick. On Debian-based systems: apt-get install icc-profiles imagemagick.
#!/bin/bash
srgb=sRGB.icm
cmyk=ISOwebcoated.icc
# extract possible color profile
profile="${f/%.*/.icc}"
convert "$f" "icc:$profile" 2>/dev/null
if cmp -s "$profile" "$srgb" ; then
# embedded profile is already srgb. Nothing to do
exit
fi
if [ -s "$profile" ]; then
# we have an embedded profile, so ImageMagick will use that anyway
convert "$f" -profile "$srgb" +profile '*' "$outfile"
else
# no embedded profile in source
if identify -format "%r" "$f" | grep -q CMYK; then
# CMYK file without embedded profile
convert "$f" -profile "$cmyk" -profile "$srgb" "$outfile"
fi
fi
Re-exporting the image using Krita seems to work well enough for me:
krita my_img.jpg --export --export-filename my_img_in_srgb.jpg
Krita is an open source Photoshop/Paint, with a(n extremely limited) command line interface. Install it with
sudo apt install krita

Resources