I have a 4000x3000, 3.7MB JPEG2000 file that I'm trying to process into cropped tiles. I do this with a command like:
convert 486.jp2 -crop 256x256+0+0 -format jpg 486_crop.jpg
This command takes 5 seconds to run on a current-model Mac Pro. ImageMagick is using the Jasper library, which I've read is very slow. I just want to make sure I'm not botching the command somehow before I abandon ImageMagick in this application.
ImageMagick has poor perf (pretty good results though). You can consider GraphicsMagick instead. A few interesting benchmarks (there is one for the crop option): GraphicsMagick 1.3.8 vs ImageMagick 6.5.8-10 Benchmark Report
On a year old Mac mini (2.53 C2D):
$ ls -hn test.jp2
-rw-r--r-- 1 501 20 10M Aug 12 23:40 test.jp2
$ time convert test.jp2 -crop 256x256 -format jpg test/%d.jpg
real 0m3.971s
user 0m3.383s
sys 0m0.535s
On a current-model quad-core Mac Pro it should run no slower.
I am using a stock version of ImageMagick from ports:
$ convert -version
Version: ImageMagick 6.6.3-0 2010-08-31 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP OpenCL
Also it is same slow when tiling PNG or plain JPEG. Seems to me that JPEG2000 isn't the issue here.
Related
I have a large number of images in the INTA format, an old SGI standard. INTA is a grayscale image with an alpha channel. All of these need to be converted to TGA files. The problem is that neither ImageMagick nor PIL/Pillow seem to be able to parse them correctly. ImageMagick can read and export them but doesn't seem to understand the alpha channel, and PIL fails to open them, with the error ValueError: Unsupported SGI image mode. The one thing that I've found that reads them successfully is GIMP:
An ideal solution would be one that is easy to invoke from a script.
For reference, here is one of the images in question (the same one seen in the screenshot): https://www.dropbox.com/s/8hoppdgtuqxsy26/girder01.inta?dl=0
It seems GDAL is able to read your image and I converted it to a greyscale+alpha PNG using:
gdal_convert YOURIMAGE.sgi result.png
You can easily get to TGA from there.
I am assuming the batching is not an issue, but it would look something like this in bash:
mkdir -p OUTPUT
for f in *.inta ; do
gdal_translate "$f" OUTPUT/"$f"
done
I had all sorts of trouble installing GDAL on macOS so I just used docker like this:
docker run --rm -v /Users:/Users osgeo/gdal:alpine-normal-latest gdal_translate /Users/mark/Downloads/image.sgi /Users/mark/Downloads/result.png
I have many PNGs uploaded by users.
However, they have white spaces around, which should be removed.
For instance:
An image like this:
Should be cropped to an image like this:
What should I do if I want to do this to all files matching *_spec.PNG files in a directory and all its subdirectories?
Example files:
Folder
|
Subfolder1 - file1_spec.png
- file2_spec.png
- file3.png
|
Subfolder2 - filea.png
- fileb1_spec.png
I need to do this to these files:
Subfolder1/file1_spec.png
Subfolder1/file2_spec.png
Subfolder2/fileb1_spec.png
Update:
OS: MacOSX Mojave 10.14.6
Imagemagick version: 7.0.10-22 Q16 x86_64 2020-06-27
I would make a COPY of your files in a spare directory before you do anything. Then go to the top directory and run:
find . -iname "*_spec.png" -exec mogrify -trim {} \;
Note that there are more efficient ways of doing this, but they are less readable and only really worth it if you have tens of thousands of files, or more. For anyone who's interested, that means using GNU Parallel and/or trimming more than one file per invocation of ImageMagick to better amortize the process creation time over multiple files.
I want to resize an image. I used ffmpeg for that. I used the following command
ffmpeg -i in.jpg -vf scale=200:200 -sws_flags lanczos out.png
Whether this command runs in CPU or GPU?? If the command is not running in GPU, how can i set it to run in GPU (NVIDIA) ??
It runs on the CPU. I don't think the PNG encoder can use the GPU, and neither does the JPEG decoder. You can try the below command and see if there's a speed or GPU utilization difference.
ffmpeg -hwaccel auto -i in.jpg -vf scale=200:200 -sws_flags lanczos out.png
How to convert whole image gallery or family album from JPG to BPG image format?
I'm looking for some batch conversion tool, application or script on Windows platform.
Input directory must be processed recursively and image quality should be preserved.
Linux command line fragment I use for this task, with current directory being gallery of '*.JPG' files, without subdirectories.
parallel -i sh -c 'convert -quality 100 {} -scale "1280x1000>" {}.png && bpgenc -q 30 {}.png -o {}.bpg && rm -f {}.png' -- *.JPG
You may adjust (or remove) resizing and change -q 30 to lower value for more quality.
It depends on ImageMagick and bpgenc.
To run in on Windows, you probably will need Cygwin.
Look at
http://www.romeolight.com/products/bpgconv/
for nice Windows converter.
2 things to mention: Currently there is options menu in top right of window. And all BPG pictures are saved into folder on your desktop called bpg_encoded.
Martin
With this Lab/TIF image (amongst others):
http://cl.ly/3D2g0M1R4036
Running convert file1.tif file1.jpg results in this distorted result when run on my server, which is Ubuntu 12.04 LTS. This is running ImageMagick 6.6.9-7:
http://cl.ly/image/3P253v2y3L2x
The same command run locally on my Mac, does not have the same issue. I've tested this locally with the version of ImageMagick installed by HomeBrew (6.8.0-10) as well as 6.6.9-7 manually compiled to compare as closely with the server as possible.
I had suspected that it might have been the version of libtiff, as the Mac has 4.0.3, and the server has 3.9.5, however I've just run a test on a fresh Ubuntu install with latest ImageMagick, and libtiff 3.9.5, and the problem is still present.
Anything obvious?
Running tiffinfo states that the colorspace of "file1.tif" is CIELab. Ubuntu's ImageMagick, installed through apt-get, will have Lab -- but not CIELab. This can be confirmed by running the following command between the two systems.
identify -list colorspace
I'm not exactly sure what the difference between the two colorspaces are (something about chromatic value,) but that would contribute to the illumination your experiencing.
A solution would be to install ImageMagick from source on you Ubuntu server/machine (which will include CIELab). Other people have experienced related issues; which, resolved after building from source.
With apt-get
Uninstall ImageMagick
Install the development packages for each dependent library (ie libtiff-dev)
Follow ImageMagick's documentation
Update:
You can also explicitly set the colorspace with the -set option. Also add the -verbose options to evaluate what ImageMagick is doing.
convert -verbose file1.tiff -set colorspace CIELab -colorspace sRGB file1.jpg
# Output
file1.tif TIFF 1451x1865 1451x1865+0+0 8-bit CIELab 1.326MB 0.110u 0:00.109
file1.tif=>file1.jpg TIFF 1451x1865 1451x1865+0+0 8-bit sRGB 411KB 0.820u 0:00.840