imagemagick,png,tiff,imagemagick-convert , Imagemagick convert tif to rgba16 png


Imagemagick convert tif to rgba16 png

Question:

Tag: imagemagick,png,tiff,imagemagick-convert

So here is my source tif image:

$ identify -verbose source.tif
Image: 
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 512x512+0+0
  Resolution: 72x72
  Print size: 7.11111x7.11111
  Units: PixelsPerInch
  Type: Palette
  Base type: TrueColor
  Endianess: MSB
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 1-bit

And I've tried: convert source.tif output.png

And here are the results:

$ identify -verbose output.png 
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 512x512+0+0
  Resolution: 28.34x28.34
  Print size: 18.0663x18.0663
  Units: PixelsPerCentimeter
  Type: Palette
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 1-bit

But I'm not seeing how to make the PNG be RGBA16. Which as I understand means it needs a 16 bit depth, and an alpha channel.


Answer:

In general, ImageMagick will use the most economical output format that is compatible with your specifications. So, if your input image doesn't have an alpha channel (i.e. transparency), your output image won't have transparency. If a 256-colour palette is adequate for the colours in your image, it will create a palettised output image. If an 8-bit output depth is adequate for your image, it will not bother creating a 16-bit output. And so on...

If you want to force ImageMagick to do something different, you have a number of options.

If you want to force true-colour, or a palettised (indexed) output file, you can do this:

convert input.png -type palette   output.png  # Force palettised (indexed) output
convert input.png -type truecolor output.png  # Force true colour output

If you want to force 8-bit or 16-bit, you can do this:

convert input.png -depth 8   output.png  # Force 8-bit output
convert input.png -depth 16  output.png  # Force 16-bit (per channel) output  

If you want to force an alpha/transparency channel, you can do:

convert input.tif -type TrueColorAlpha output.png  # Force a true color output with transparency

And you can combine these too. If you want to see the type options, use this command:

identify -list type

Bilevel
ColorSeparation
ColorSeparationAlpha
ColorSeparationMatte
Grayscale
GrayscaleAlpha
GrayscaleMatte
Optimize
Palette
PaletteBilevelAlpha
PaletteBilevelMatte
PaletteAlpha
PaletteMatte
TrueColorAlpha
TrueColorMatte
TrueColor

Furthermore, specifically in the case of PNG files, you can also force the output by specifying the PNG type in capitals, followed by a colon in front of the output filename, thus:

convert input.tif PNG64:output.png     # Force 64-bit RGBA (3 channels @ 16-bits each, plus alpha)
convert input.tif PNG32:output.png     # Force 32-bit RGBA (3 channels @ 8-bits each, plus alpha)
convert input.tif PNG48:output.png     # Force 48-bit output (3 channels @ 16-bits each, no alpha)
convert input.tif PNG24:output.png     # Force 24-bit output (3 channels @ 8-bits each, no alpha)

So the short answer is

convert input.tif PNG64:output.png

or

convert input.tif -depth 16 -type TrueColorAlpha output.png

Beware though, ImageMagick will override the second version if no alpha channel is present in your input image, whereas it will not do that if you use PNG64:.


Related:


PNG transparent backgrounds appearing black when using Android Studio


android,android-studio,png,adt,android-drawable
The social icons below (for fb, twitter, mail and share) are circular PNGs with transparent backgrounds. When I use the code and exact same images in Eclipse, I get transparent background but when build and run with Android Studio, I get black backgrounds. See details below. Images are the same....

C++ Opengl - How to load tgas and pngs in modern OpenGL? [on hold]


image,opengl,c++11,png,tga
I am looking for a way to load tgas and pngs in C++ Opengl - I dislike the idea of using a library though. Is there any sample code / links / advice you could give me in this topic?...

Use chop before resize in Imagemagick


ruby-on-rails-4,imagemagick,paperclip
I am using paperclip gem to process images. In some images, I need to chop the top 35 pixels of the source image and then do the conversions and processing Currently I am using :convert_options => { all: lambda{ |instance| "#{!instance.chop_top.blank? ? '-chop 0x35' : '' } -limit memory 64...

Skip bytes in ByteArray Java


java,png,bytearray,skip
My app reads a png-like file (in byte) and stores bytes into a byteArray. This is the method I use : public static byte[] read(File file) throws IOException { byte []buffer = new byte[(int) file.length()]; InputStream ios = null; try { ios = new FileInputStream(file); if ( ios.read(buffer) == -1...

TCropping images with loop in imagemagick


bash,imagemagick
A pretty basic question but I'm new to Imagemagick (and bash) and I'm having trouble batch cropping images in a folder. I've tried using a loop: for image in '/home/donald/Desktop/New Folder'*.jpg; do convert "$image" -gravity center -crop 95X95% "${image%.jpg}"-modified.jpg done but it returns: convert.im6: unable to open image `/home/donald/Desktop/New Folder/*.jpg':...

How to store ImageMagick output into Bash variable (and then use it)?


bash,imagemagick,imagemagick-convert
I use ImageMagick and need to do conditional resize of images. For that I store results of the identify tool into variables. $infile='test.jpg' width=$(identify -ping -format %w $infile) height=$(identify -ping -format %h $infile) But before resizing I want to do some transformations that change image size: -trim and -shave. So...

worklight server preview wont show png resources anymore after configuring it to serve svg


svg,png,worklight
I ran in the problem where svg images were not loading using WorkLight preview. I found the solution for that here: How can I configure Worklight to serve *.svg files with contentType=image/xml+svg? After adding these lines <mimeTypes> <type>svg=image/svg+xml</type> </mimeTypes> svg files appeared on preview, but now i can't load png...

Rapidly open 1,-1 data file as image


image,imagemagick
I'm working on a project that produces data files that are square matrices of numbers, either 1 or -1. I need to visualize this as images, and what I do now is using Matlab to open them, the matlab function imshow automatically draws those kind of matrices as monochrome black...

how to divide image into three equal parts in php imagemagick and combine with some padding and output as single image


php,imagemagick
I want to display an image into three parts as triptych with the help of imagemagick PHP library. I saw the same example here http://www.rubbleimages.com/Canvas.php. Can anyone help me on this issue please ...

Magick++ not loading from blog


c++,imagemagick,physfs
I am using Magick++ to load some images. Because I want to wrap PhysFS for all of my image loads, I needed to load an image by blob instead of file path. This code: Magick::Image test("path/to/some.png"); Works without issue. However once I do a blob I get an exception: PhysFS::ifstream...

Find edges (border of rectangle) inside an image


python,imagemagick,image-manipulation,edge-detection
I have an image of a sticky note on a background (say a wall, or a laptop) and I want to detect the edges of the sticky note (rough detection also works fine) so that i can run a crop on it. I plan on using ImageMagick for the actual...

How to find the brightest pixel?


imagemagick
How do I find the brightness (i.e. V in HSV) of the brightest pixel in an image? I have a large collection of images that will be used as background assets. In order to make sure there are no bright spots that may distract the viewer, I'd like to find...

How can I convert PNG to GIF keeping the transparency?


delphi,graphics,png,gif
How can I convert PNG to GIF keeping the transparency? I would have hoped that using the Assign( ) method would work but it doesn't seem to migrate transparency. In the GIF, it's represented as black. png:=TPngImage.Create; try png.LoadFromFile(sFile); // comes from file: png.TransparencyMode; // comes from file: png.Transparent //...

ImageMagick command without intermediary file fails


imagemagick,imagemagick-convert
I'm working on the example from ImageMagick called "Gel" Effects on the ImageMagick Example pages. Instead of executing the ImageMagick script in many steps with intermediary images, I want to do it in ONE step with no intermediary files. My code looks like this (95% same as the example): convert.exe...

ImageMagick : Compose with results of multiple convert


imagemagick,imagemagick-convert
I want to create an image from to others, which are results of convert operations their self, without saving intermediate results to file system. Long explanation: I have two images, the two needs specific transformations : avatar.jpg needs to be transformed to a rounded image -> rounded-avatar.jpg background.jpg needs to...

Imagick Interprets external image as HTML


php,imagemagick,imagick
The problem I'm having is that when saving an image from a specific external website (not all websites), I get an error where the image is interpreted as html and not as another image format. So far, this website is the only site that I've experienced this problem on, but...

Magick++ to display an image with CGI


c++,imagemagick,cgi,jpeg,magick++
I recently began using Magick++ (C++ API for ImageMagick) with the goal of creating a website that could display randomly generated images. I am trying to write a CGI script which would create a JPEG Image, set the color of its pixels, and then return the image information as Content-type:...

I can't convert with ImageMagick


php,centos,imagemagick
I'm using ImageMagick to convert a PDF file. I use this PHP snippet: $cadena = "/usr/local/bin/convert -density 100 -colorspace rgb ".$name_path." ".$images_path."/convert.png"; shell_exec($cadena); where $name_path is the PDF file directory and $images_path is the images directory. This code in console (CentOS) works perfectly. But when I try to use shell_exec()...

How to apply pagecurl effect on a static image by PHP


php,imagemagick,page-curl
I want to apply a curl or peel effect on an image using PHP and ImageMagick. I tried various libraries in PHP, but only ImageMagick may do the same. I want the same output as here: ...

Png Image instead of Text in PHP [closed]


php,png
Hello i want to show a png image instead of text in my php file for my site. My Code: function format_age($t) { if ($t<30) return "LIVE"; return sprintf("%d%s%d%s%d%s", floor($t/86400), ' Tage ', ($t/3600)%24,' Std. ', ($t/60)%60,' Min.'); } So instead of "LIVE" i want to show an png Image....

RMagic gem require error. RMagick2.so cannot be opened


ruby-on-rails,ruby,imagemagick,rmagick
When I try the following in my controller, require 'RMagick' and running RAILS_ENV=production rake gems:install I am getting the following error. rake aborted! libMagickCore.so.2: cannot open shared object file: No such file or directory - /usr/lib64/ruby/gems/1.8/gems/rmagick-2.10.0/lib/RMagick2.so When I checked, the file RMagick2.so is present in the directory. ImageMagick is also...

Calculate the main memory consumption of ImageMagick convert when appending images


imagemagick,imagemagick-convert
I append several PNG images with the ImageMagick convert tool. convert -set colorspace RGB `ls *.png` -append outout.png This are the color parameters of the input files: $ identify input1.png input1.png PNG 9600x1800 9600x7200+0+0 8-bit sRGB 355KB 0.000u 0:00.000 4 input files exist with identical parameters. The output file has...

How can I replace the white rectangle within an image using ImageMagick?


php,image-processing,imagemagick
Overview: The first picture is my original image. Here I want to replace the white rectangle shown with another image. My approach: I have created a mask image using floodfill and it looks as: Problem: Now I would like to get the distance or co-ordinates of the rectangle in the...

matplotlib animation.save to animated gif very slow


python,matplotlib,imagemagick,animated-gif
I'm animating a convergence process that I'm simulating in an IPython 3.1 notebook. I'm visualizing the scatter plot result in a matplotlib animation, which I'm writing out to an animated gif via ImageMagick. There are 3000 frames, each with about 5000 points. I'm not sure exactly how matplotlib creates these...

How to lighten an image using ImageMagick like when using compare?


imagemagick
As you see in the answer “Diff” an image using ImageMagick, the "delta" image is somehow lightened: How would I lighten an image just like that using ImageMagick?...

How to properly generate an A3 sized pdf from jpg with convert


imagemagick,pdf-generation,image-resizing,imagemagick-convert
On linux using the imagemagick tool convert, I want to convert my large jpg files into A3 pdfs <= 10MB in order to print those files with the best quality at the store. When running: $ convert summer-bokeh.jpg -quality 100 -density 300 -resize 2480x3508! summer_resized.pdf I'm trying to force the...

ImageMagick - Making 2 GIFs into side by side GIFs using IM convert


image,unix,imagemagick,imagemagick-convert
I have 2 GIFs that are the same length. I want to put the GIFs beside each other to have 1 GIF with both playing at the same time. I have tried to use the convert tool with: convert +append 1.gif1 2.gif output.gif However, this seems to blend all the...

Does anyone know how to convert to little endian .pfm file from ImageMagic?


imagemagick
I'm looking for method about to convert little endian.pfm file from imageMagick. As I know we can get a pfm file like this. convert input.bmp output.pfm This output file is made by Big endian. But I want to convert as Little endian. So is there any method to convert to...

CarrierWave/MiniMagick avatar not displaying


ruby-on-rails,ruby,imagemagick,carrierwave,minimagick
Hey so I'm having some trouble with CarrierWave & MiniMagick this morning uploaded avatar images are not displaying correctly as you can see highlighted in this screenshot I've dug around the html and controllers and can't find what's wrong so I'll post all that here and see if a second...

Converting 32x32 StdPicture icons to PNG


arrays,vb6,png
I am trying to convert an StdPicture into a PNG before encoding it to Base64 to be sent over XML. I've gotten the Base64 encoding portion down (see near end of function EncodeImageToBase64()) however I am having trouble converting the StdPicture object into a PNG byte array. Here's my function:...

C++ Bitmap Resource (RT_BITMAP) and PNG Image Format


c++,bitmap,png
An application I'm developing displays various PNG images to the user in a window, and it works fine. My question is more on the grounds on HOW my PNG's are stored in the PE. Currently, the PNG's are stored in the executable as a resource, under the RT_RCDATA Resource Type,...

Zoomming into an image with ImageMagick


image,imagemagick
I would like to zoom into an image test.png. That is, as a silly example, I would like to go from this to this The only way I was able to do it was with convert -resize 110% test.png -gravity Center \ -crop 800x600+0+0 +repage 1.png This is re-scaling the...

Trying to remove background and make it transparent in c++, using magick++


c++,imagemagick,magick++
I am having an image "objects.png" with a red background and I'm trying to make the background transparent. The code is straight forward but somehow I am not able to get the desired result. I am quite new to this ImageMagick business and this is my first program using Magick++....

Why use ImageMagick in CMS like MediaWiki instead of simply using browser methods?


imagemagick,mediawiki,graphicsmagick
Can somebody explain to me why I should possibly use ImageMagick (or the fork GraphicsMagick) in a CMS instead of simply displaying and sizing my images via CSS? The browser methods cannot fail and are automatically updated on client side, the ImageMagick-binary can fail on the server and I have...

Doing custom avatars with nodejs


node.js,png
So I'm wondering if this http://bokehman.com/do_it_yourself_avatars/ is also possible in nodejs. Basically I want to make a png out of several other pngs (all the same size) that are just stacked one over each other and then save it on the server. Can I do that? A short example would...

Use image Button with transparent color area


c#,button,png
I have a picture in PNG with transparent and normal color. I use this for one Button: this.Button1.BackColor = System.Drawing.Color.Transparent; this.Button1.BackgroundImage = Image; this.Button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.Button1.FlatAppearance.BorderSize = 0; this.Button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; this.Button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; this.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;...

CImg failed to recognize the format “jpeg”


xcode,imagemagick,cimg
To load image, I installed the CImg library in my mac(OSX 10.10). Luckily I managed to display the bmp picture, but I failed to load and display other formats like png or jpg. Then I installed the ImageMagic which is downloaded from http://cactuslab.com/imagemagick/ and then run the program. The errors...

Why does Delphi XE7 change PNG image on every FMX form save?


delphi,png,firemonkey,delphi-xe7
I have a form with many custom firemonkey components where each contain multiple bitmaps (loaded from PNG image files). Every time the form is saved, the binary data of the PNG images change in the FMX file! This messes up my version control log (SVN), as changing just one property...

Imagemagick crop while keeping size


imagemagick,imagemagick-convert
I want to crop the top 10 pixels of an image, but to keep the width All exmaples I found look like convert rose: -crop 90x60-10-10 crop_all.gif I need to supply the 90x60 so for the result size How can I crop with something like +0+10 and not supply a...

How to use GraphicsMagick to negate the alpha channel of a picture


imagemagick,graphicsmagick
I want to invert a image with transparent background, i.e. from , transparent background to , transparent "We" In ImageMagick, we can do this by convert 1cut.png -channel a -negate +channel 1cut_nega.png as mentioned in http://www.imagemagick.org/discourse-server/viewtopic.php?t=18842 What is the equivalent command in GraphicsMagick? If I use $ gm convert -channel...

Nodejs image crop by coordinates


node.js,image,imagemagick,crop
Is there is way where we can give x, y coordinates while cropoing image. Currently what i am using is Imagemagick im.crop({ srcPath: upload_path+media_file_name, dstPath: upload_path+"thumb_"+media_file_name, width: 350, height: 210, quality: 1, gravity: 'Center' }, function(err, stdout, stderr){ }; This code is working but i haven't got luck with x,...

Why the first byte of .png file is 0x89?


file,png,formats
I am currently reading about PNG file format. It turns out that the first byte of the file is specified to be equal to 0x89. I am wondering what are the reasons of the value of that byte. What I've already learned about the format is that the first byte...

Uploading PNG to Website Server


php,mysql,image,png
I have seen loads of other topics and I've tried them all. Can someone please help with why this script won't upload PNG files? Blank PNG image being displayed. $image = $_FILES['file']['tmp_name']; $image_name = $_FILES['file']['name']; $ext = pathinfo($image_name, PATHINFO_EXTENSION); $location = "Profiles/{$user}/Picture/{$image_name}"; $new_image = imagecreatetruecolor(100, 100); $source_image = imagecreatefrompng($image); imagealphablending($source_image,...

Create two sizes of an image using one ImageMagick command


image,imagemagick,image-resizing
I am using ImageMagick to generate small size JPEG versions of large TIFF images. For each TIFF image I must generate two smaller JPEG versions. I am currently using two convert commands: convert.exe 4096-by-3072px-120mb.tif -resize "1024x>" -strip -interlace Plane 1024px-wide-for-web.jpg convert.exe 4096-by-3072px-120mb.tif -resize "1600x>" -strip -interlace Plane 1600px-wide-for-web.jpg Converting TIFF...

How do I grep GZ files to extract PNG files?


grep,png,gz
Ok, so I have a tone of .GZ files in a folder, and I'm looking to recursively look through each one of them and extract all the PNG files into another destination folder. How would I do that? EDIT: I've been using this command from the terminal to find a...

Rename a bunch of PNG images with “.jpg” extension to “.png”


image,bash,scripting,png,jpeg
So I have a folder with thousands of image files, all of them saved as .jpg. The problem is that some of those files are actually PNG image files, so they don't open in a lot of programs, unless I manually change their extension to .png. For example, the Ubuntu...

Convert multiple images with ImageMagick


imagemagick
I want to convert all my PNGs to PNG using ImageMagick (I need this because AndroidStudio has some issue with the original PNGs. ImageMagick is able to fix this issue by re-exporting the PNG.) If I do: convert a.png a.png it works. But how do I do this for many...

PHP: PNG readfile encoding issue


php,encoding,png,php-gd
I have this code which outputs a PNG file to the browser header('Content-type: image/png'); header("Content-Length: " . filesize($cache_file)); readfile($cache_file); exit(); The file $cache_file was saved like this imagepng(self::$image, self::$cache); The browser is displaying a broken image. When I download it and open it with npp, I find that it's encoded...

Consistent PNG Bit output with PHP Imagick


php,png,fpdf,imagick
I have the following code to create a png swatch with a drop shadow (to dynamically insert in a PDF file using FPDF.) $shadowSwatch = $pm->clone() ; $shadowSwatch->setImageBackgroundColor('#000000') ; //Angle & Offset of Drop Shadow based on photoshop settings $angle = deg2rad(45) ; $xOffset = round(sin($angle) * 18, 0) ;...

NodeJs runing ImageMagick convert all images from directory


node.js,imagemagick
This is basic imagemagick setup for node.js that i came across lately. I understand that question im asking is very newbie but im new to node js and imagemagick and i wanted to try to make it dynamic. Current script bellow is croping one specific file, is there a way...