Rescaling XPM image - image

ALL,
I have an XPM image with the size of 10x10. What I would like to do is to scale it so that the size becomes 16x16.
Does anybody knows how I can do that?
Thank you.

With ImageMagick, which is installed on most Linux distros, and is available for macOS and Windows:
convert small.xpm -scale 16x16 bigger.xpm

Related

Certain JPEG images not visible in Adobe Form while others are

I have this strange problem where certain JPEG images are not visible in Adobe Form while others are. What could be causing this?
Thank you in advance,
Joshua
This problem is related to the colorspace of the JPEG image. Convert the JPEG to the YCbCr colorspace to fix it. You can do so with ImageMagick for example. This Linux command would do the trick:
mogrify -colorspace YCbCr <your_image.jpeg>

How to make an almost black image very high contrast

I am seeing the following image in a paper:
However, when I download the associated dataset with the paper, the images are like this:
How can I make the almost black images in the dataset looking like the one in the paper?
link to dataset: http://www.cs.bu.edu/~betke/research/HRMF2/
link to paper: http://people.bu.edu/breslav/084.pdf
The contents of this dataset is saved as 16 png data. But ordinary display has only 8bit dynamic range. So we cannot display them without windowing. Please try to use ImageJ, it can map 16bit data into visible 8bit data.
https://imagej.nih.gov/ij/index.html
It can show as following.
As the other answers rightly say, the images are in 16-bit PNG format. You can convert one to a conventionally scaled, viewable JPEG with ImageMagick which is installed on most Linux distros and is available for macOS and Windows.
So, in Terminal:
magick 183.png -auto-level 183.jpg
If you would like to convert all 800 images to JPEGs in one go, you can use ImageMagick's mogrify like this:
magick mogrify -format JPEG -auto-level *png
Note that if your ImageMagick is the older v6 (as opposed to the v7 commands I used) the two commands become:
convert 183.png -auto-level 183.jpg
mogrify -format JPEG -auto-level *png
The images in this dataset have high dynamic range of 16-bits per pixel. Image viewer you are using is mapping 16-bit pixels to 8-bit ones, in order to display them (most displays can only effectively handle 8 or 10 bits of brightness). Most image viewers will just truncate the least significant 8 bits, which in your case produces nearly black image. To get better results, use ImageJ (Fiji distribution is the easiest way to get started), which displays this:

How to resize an image with Rmagick crop if necessary.

I'm trying to create an image server that is riapi (https://github.com/riapi/riapi/blob/master/level-1.md) compliant.
One of the required resize modes is crop (the image will be minimally cropped evenly to match the required aspect ratio). Anyone know which of Rmagick's million methods I'm looking for?
Looks like resize_to_fill does what I was looking for. I just miss-read the documentation.

imagemagick resizing and quality PNG

In my application I need to resize and make the quality on PNG files poorer.
In full size the PNGs are 3100x4400px using 2,20MB disk space.
When running the following command:
convert -resize 1400 -quality 10 input.png output.png
the images are resized to 1400x2000 using 5,33MB disk space.
So my question is: How can I reduce the file size?
You can further reduce quality of PNG by using posterization:
https://github.com/pornel/mediancut-posterizer (Mac GUI)
This is a lossy operation that allows zlib to compress better.
Convert image to PNG8 using pngquant.
It reduces images to 256 colors, so quality depends on the type of image, but pngquant makes very good palettes, so you might be surprised how often it works.
Use Zopfli-png or AdvPNG to re-compress images better.
This is lossless and recommended for all images if you have CPU cycles to spare.
After using imagemagick to resize, you can compress the image using pngquant.
On mac (with homebrew) brew install pngquant then:
pngquant <filename.png>
This will create a new image filename-fs8.png that is normally much smaller in size.
Help page says, that -quality option used with PNG sets the compression level for zlib, where (roughly) 0 is the worst compression, 100 - is the best (default is 75). So try to set -quality to 100 or even remove the option.
Another method is to specify PNG:compression-level=N, PNG:compression-strategy=N and PNG:compression-filter=N to achieve even better results.
http://www.imagemagick.org/script/command-line-options.php#quality
For lazy people that arrived here wanting to paste in a one liner:
mogrify -resize 50% -quality 50 *.png && pngquant *.png --ext .png --force
This modifies all of the pngs in the current directory in place, so make sure you have a backup. Modify your resize and quality parameters as suits your needs. I did a quick experiment and mogrify first, then pngquant, resulted in significantly smaller image size.
The ubuntu package for pngquant is called "pngquant" but I had it installed already on 20.04LTS so seems like it may be there by default.
I found that the best way was to use the
- density [value]
parameter.

Increase image quality from dvipng without increasing image size?

For dvipng, the -D option increases the dpi of the image but also increases the image size, and the -Q option improves antialiasing but doesn't do enough. Is there a way to increase the image resolution and quality without increasing image size?
I would suggest that you use -D and -Q, and then post-process the generated image using imagemagick's mogrify or something similar to scale the image back. The external program will probably do a better job at doing good scaling.
Part of this may have to do with the way DVI files are rendered. You may have better luck using PDF instead of DVI, which is what I did when I needed PNGs from LaTeX sources.
If the -Q option has any effect at all, this means that you are using bitmapped fonts, PK fonts. This is the oldest font format available to TeX, and will not have real good performance.
I suggest you install FreeType, and rebuild dvipng. FreeType has proper antialiasing with proper hinting.
What system are you using?

Resources