Lightweight command-line image resizer? - imagemagick

I'm looking for an image resizer / thumbnailer that is lightweight and efficient. Something that does a good job with all image types, but most importantly jpeg and png.
I've looked into ImageMagick and GraphicsMagick, but they are too heavy. This is something I want to distribute with my app, so the smaller the better. I don't need all the functionality of *Magick, just simple resizing.
I've found the FreeImage library which people seem to like as a light library. Does anyone know if there's a simple command-line utility that wraps FreeImage?
Thanks!

Although ImageMagick is pretty big (36.2MB), you only need the convert.exe or mogrify.exe binary, depending on whether you want to create a new image (convert), or overwrite the existing one (mogrify).
Download the no-installer version of ImageMagick (currently ImageMagick-6.8.6-8-Q16-x86-windows.zip), then extract the binary you need.
I took mogrify.exe - a total of 5.66MB; not bad!

Have a look at the netpbm toolkit, the toolkit is just a bunch of small single purpose command line programs that you wire together using pipes. You might be able to find what you need in there.

On linux/OSX can use sips
sips -Z 640 *.jpg

i have bulk image contain in a directory name with test And i want to re-size all of them single command line
cd /test/
find . -name "*.jpg" -exec convert -quality 75 {} /var/www/html/converted/{} \;
/var/www/html/converted/ this used for where converted image will save .

Related

Looking for a way to create compressed png files in lua/luajit

I'm writing a mod for a game that uses lua/luajit as a scripting language and I would like to create a png file dynamically using lua. I've been googling for a png library/module but could only find ones that merely read pngs (like https://github.com/Didericis/png-lua or https://luapower.com/libpng), or create uncompressed pngs: https://github.com/wyozi/lua-pngencoder
On my search I have stumbled upon libpng and thought, maybe I could simply load that dll using ffi and use the functions that way. But the problem is that is waaaay too complicated for me, since I'm not familiar with C and furthermore libpng seems to be a huuuuuge complicated library.
So, is there any simple way (module/library) that I missed and didn't find on google?
I just need very simple functionality, create a png, set the pixels, save it as a compressed png file.

Extract bezier paths from a png

I want to extract bezier paths from a png like this.
sample image
potrace doesn't support reading PNG files natively. You'd need to convert PNG images to another supported format first. http://potrace.sourceforge.net/faq.html#formats
However potrace is licensed under the GPL so while it does compile for iOS you may not want to use it as part of an app. Is it possible to compile potrace for iOS? There is a non-GPL version of potrace available, but it isn't free.
Depending on the complexity of the PNG images you want to convert, you may get less than ideal results anyway.
If you update your question with more detail about what you are trying to achieve it might be possible to give a better answer.

How to get imagemagick to support .flif and .bpg formats?

For quite some time now there have been several image codecs which provide significant improvements over PNG and JPG, however the latter still remain dominant.
Two formats in particular that I'd really like to see getting more adoption are FLIF and BPG. They seem superior in every possible way to JPG and PNG (except for lacking market acceptance). Especially FLIF seems extremely promising.
TL;DR = Besides supporting them in my own software, is there a way to get FLIF and BPG support in imagemagick?
The ChangeLog for ImageMagick says
2015-06-25 6.9.1-7 ... * Support BPG image format
There's no direct BPG support in the ImageMagick source code, but config/delegates.xml lists delegates "bpgdec" and "bpgenc" which convert BPG files to and from PNG files which then get processed by ImageMagick. You would have to supply those delegates if they aren't already on your system. You can download the sources for bpgdec and bpgenc from
http://bellard.org/bpg/
There's nothing about FLIF in the ChangeLog, but a "pull request" for FLIF support was recently applied, and coders/flif.c exists in the ImageMagick sources (it requires a separate libflif to work). You can download the source code for libflif from https://github.com/FLIF-hub/FLIF
I haven't tested either feature.
bpgdec, bpgen, and libflif are all LGPL-licensed, and a reduced version of bpgdec is available under a BSD license.
To get imagicmagick to work with .bpg you have to compile it separate from what is already there. In other words, you have to add it in. So download the source code and it doesn't compile. Give up and use something else or try this because I got it to work
use apt-get and install
libpng*
libsdl1*
libsdl2*
libsdl-image*
cmake
libjpeg*
and maybe libjpg*
decompress the .bpg files you downloaded and just
use the command
make and sudo make install
AFTER that imagemagick will work with libpg and will not give an error of a missing delegate..

Inkscape screws up EPS files

I have been trying to use Inkscape to prepare artwork graphics for my scientific papers. I use LaTeX, and I need my figures to be prepared as high-quality Encapsulated PostScript (EPS) images. The work order is as follows. First, I plot parts of my figure using matplotlib and save them in EPS format. Second, I launch Inkscape and import the EPS files. Using Inkscape I compose a figure, leaving needed objects, killing unneeded, and adding some markups. So I used to do when I worked with CorelDraw in Windows, but now I work in Linux.
Unfortunately, Inkscape damages EPS files: it changes the colors and does not save all the objects. Over last years I tried to search for a solution, but I cannot find that people complained. The complaints (found on the Web) are related to something like "incorrect font rendering" when exporting from svg to eps or back. (For me this is not a problem - the text always can be represented as curves).
I currently work in Mandriva Linux 2010 and use Inkscape version 0.47 r22583 (Jan 14 2010). Somewhere I read that such problems could be caused by some outdated versions of cairo - mine is 1.9.14. I spend a lot of effort to build newer cairo (1.12.14), but I am still far from the purpose. I got confused in 32 and 64-bit libraries coexisting in my system...
I would be very grateful to anyone who has similar problems and, may be, advanced further towards the solution. Let me illustrate the problem.
Sorry, I do not have enough reputation points to neither post images nor insert more than 2 links, so, please take a look at the copy of this post with the images in my livejournal page:
http://benkev.livejournal.com/1093.html
The figure captions are below.
(1) Here are the three eps images I would like to combine in one figure:
(2) Here is what I get after importing the images in Inkscape and saving in SVG format. Note color and resolution distortion. Also, I draw three red circles around the feature of interest.
(3) Here is what I get when I export this figure to EPS file. One can notice that one of the three red circles gone: only two circles left!
Thank you!
This appears to be a bug in inkscape. The following steps might help:
Open the svg file in inkscape.
Select all (Ctrl+A)
Un-group (Ctrl+Shift+G). you may need to repeat this step several times.
Save the result as eps format.
For what it's worth after more than one year: I've been experiencing the same problems with Inkscape V0.48: the EPS was missing items when opened in other software (e.g. Latex).
I didn't completely solve the problem, but I found that it helped to remove groups. Simply select all components and keep ungrouping until there are no groups left. Save as EPS and the result should be better.
If there are still items missing, try to use 'raise selection up to top' on the missing items and save again.
I know this is old, but the bug is still present in Inkscape so here's my two cents. My workaround is to save a copy of my project as "Plain svg". And export that as eps.
I hope it helps!
I created a new layer and moved the text which was not showing up in the EPS to this layer. Then it was showing up in the exported EPS file.
P.S. Make sure you make the new layer below the current layer and move text there.
It is a bug in inkscape (0.91 Window) but easy fix. Save directly into pdf from inkscape and then from pdf file save as to eps. Work like a charm for me.
A permanent solution for this problem is to export your *SVG to a *PNG and then export the *PNG (e. g. via the free Software GIMP) as an *EPS file type. The missing items are always included when I use this approach.

How to minimize OpenCv library size?

I'm looking to minimize the size of my android ndk built library.
I have started with the pre-built OpenCv libraries for Android and as of now the size of my lib is about 3MB. How can I minimize it's size?
I only need read/write files capability, png encode/decode, jpeg decoder and the typical image manipulation functions from OpenCv such as resize and cvtColor.
Any pointers greatly appreciated!
You've probably moved on with your project by now, Jona, but others not using the cmake-gui may like a command-line example. i.e. if you didn't want the CCALIB module, you could build like this:
cmake -DBUILD_OPENCV_CCALIB=OFF [other cmake flags] ../
Manipulating build flags may not cover all the module exclusions you would like, however, it's probably a good place to start. To see the list of flag options, open CMakeLists.txt file (top of the opencv source directory).
Turning on/off flags also won't break your builds as much as manually commenting-out code.
The OpenCV library has several modules, you might consider leaving out modules like 'highgui' and 'gpu', and maybe more depending on what you need and don't need. Anyhow, I am not quite sure what you need. Maybe you should use a different smaller library instead, as reading, writing, decoding, converting, etc are not really Computer Vision operations, like a Hough transform or a distance map
One you might consider is cimg btw, you can easily strip that one down as it simply just defines more and more functions as part of the cimg class.
Good luck!

Resources