Tuesday, March 14, 2017

Non GPL libsndfile alternative to read wav files. tinysndfile with Apache License, Version 2.0

A lot of people avoid using GPL in non-free software due to its imposed restrictions. I decided to use libsndfile which is GPL. But many people claim different restrictions as per GPL and i decided to avoid using this library because there were so many conflicting statements that i ended up with no conclusion. I still fear if someone claims for my GPL based projects on PlayStore to provide full source code!. I am not even maintaining many of them. If i am using GPL to process a wav file and i provide enough methods to enhance that GPL part of code why i am forced to provide rest of code?. This way one can even claim whole operating system to become GPL!!!. That's why Android Project decided to go with Apache License.


With above case in mind many developers built software with simpler licenses not imposing loads of terms and conditions. tinysndfile is such alternative to libsndfile. This library is available here https://android.googlesource.com/platform/system/media/+/master/audio_utils. tinysndfile is Android only and requires some editing to make it work on *NIX. I have done that work and stripped audio_utils to extract out tinysndfile. Using this library wav file can be read to get PCM data. It supports common wav files. Whether its a commercial project or a free software use it without fear of any legal issues.



Why tinysndfile?


Look at libsndfile page http://www.mega-nerd.com/libsndfile/ . Below text is read from the same -


"Licensing

libsndfile is released under the terms of the GNU Lesser General Public License, of which there are two versions; version 2.1 and version 3. To maximise the compatibility of libsndfile, the user may choose to use libsndfile under either of the above two licenses. You can also read a simple explanation of the ideas behind the GPL and the LGPL here.

You can use libsndfile with Free Software, Open Source, proprietary, shareware or other closed source applications as long as libsndfile is used as a dynamically loaded library and you abide by a small number of other conditions (read the LGPL for more info). With applications released under the GNU GPL you can also use libsndfile statically linked to your application.

I would like to see libsndfile used as widely as possible but I would prefer it if you released software that uses libsndfile as Free Software or Open Source. However, if you put in a great deal of effort building a significant application which simply uses libsndfile for file I/O, then I have no problem with you releasing that as closed source and charging as much money as you want for it as long as you abide by the license."



Small number of other terms are so much that i avoided using it. Such a great software i decide not to use :(. Example of such other terms are -


https://www.gnu.org/licenses/why-not-lgpl.en.html


https://source.android.com/source/licenses.html#why-apache-software-license



Don't forget to read the GPL section -

http://www.cgal.org/license.html




Download links:

You can download my non-Android version of tinysndfile from here https://github.com/bindeshkumarsingh/android-native-libs/blob/master/tinysndfile-src-nix.7z

Compiling libjpeg-turbo 1.5.1 on Android

I tried to build Turbo JPEG libary using cmake and then encountered "Platform not supported by this build system.  Use autotools instead.". This is because the author has hard-coded cmake script for windows platform only. I tried to modify cmake and build turbo-jpeg but before that i built it using configure script.


I created below script to build turbo-jpeg. The configure script automatically enabled NEON support after checking ARM environment. Anyone can use this script by changing variables like NDK, ARCH, PLATFORM etc.

This script will not work without some editing. There may be other ways to compile successfully but i was getting SIZE_MAX undefined error so i simply added #include in jmemmgr.c and completed building the binaries. File BUILDING.md has instructions to build Android version.


AndroidBuild.sh :
#!/bin/sh
# http://www.ourinnovativemind.in
# http://www.gamesgreh.in

export CONFIGURATION_OPTIONS="--disable-shared --enable-static"


# use custom build environment

# installation directory
export PREFIX=`pwd`/prefix

# Path of NDK. For simplicity make symlinks in home directories
export NDK=/home/bindesh/bin/ndk/

# processor specific libraries and includes.
# Suffix for arch-???. arch-arm  arch-arm64  arch-mips  arch-mips64  arch-x86  arch-x86_64
export ARCH=arm

# compiler for processor
export CROSS_COMPILE=arm-linux-androideabi

# Android platform version
export PLATFORM=android-9

# GCC compiler version
export GCC_VERSION=4.9


# Getting toolchain directory inside NDK from variables set above
# Hardcoded for linux running on x86 cpu 64-Bit
export ANDROID_PREFIX=${NDK}/toolchains/$CROSS_COMPILE-$GCC_VERSION/prebuilt/linux-x86_64

# SYSROOT. usr dir i.e. usr/include, usr/lib
export SYSROOT=${NDK}/platforms/$PLATFORM/arch-$ARCH
export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}

# Some compiler and binutils. More might be needed depending on source. 
export CPP=${CROSS_PATH}-cpp
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-gcc
export CXX=${CROSS_PATH}-g++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib


# package configuration file save location
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig

# Flags for compiler
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"

./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@" $CONFIGURATION_OPTIONS
make
make install



Below is the log file dumped after running this script. The resulting binaries can be downloaded from https://github.com/bindeshkumarsingh/android-native-libs/blob/master/libjpeg-turbo-1.5.1_Android.7z.

I haven't used this build for making a libjpeg client app. I expect it will work.


log :
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-androideabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking how to run the C preprocessor... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
checking for arm-linux-androideabi-gcc... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... (cached) yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... (cached) none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... (cached) yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... (cached) gcc3
checking for arm-linux-androideabi-ar... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking the archiver (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar) interface... ar
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
checking if the linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm
checking the name lister (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to arm-unknown-linux-androideabi format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld option to reload object files... -r
checking for arm-linux-androideabi-objdump... no
checking for objdump... objdump
configure: WARNING: using cross tools not prefixed with host triplet
checking how to recognize dependent libraries... pass_all
checking for arm-linux-androideabi-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-androideabi-ar... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking for archiver @FILE support... @
checking for arm-linux-androideabi-strip... strip
checking for arm-linux-androideabi-ranlib... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib
checking command to parse /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm output from /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc object... ok
checking for sysroot... /home/bindesh/bin/ndk//platforms/android-9/arch-arm
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-linux-androideabi-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -fno-rtti -fno-exceptions... no
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to produce PIC... -fPIC -DPIC
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc PIC flag -fPIC -DPIC works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc static flag -static works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... (cached) yes
checking whether the /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes
checking dynamic linker characteristics... Android linker
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether ln -s works... yes
checking for arm-linux-androideabi-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking size of size_t... 4
checking whether compiler supports pointers to undefined structures... yes
checking whether __SUNPRO_C is declared... no
checking for ANSI C header files... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for string.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether char is unsigned... yes
checking for inline... inline
checking for size_t... yes
checking for unsigned char... yes
checking for unsigned short... yes
checking if right shift is signed... Assuming that right shift is signed on target machine.
checking for memset... yes
checking for memcpy... yes
checking libjpeg API version... 6.2
checking whether to include in-memory source/destination managers... yes
checking libjpeg shared library version... 62.2.0
checking whether the linker supports version scripts... yes (GNU style)
checking whether to use version script when building libjpeg-turbo... yes
checking for inline... inline __attribute__((always_inline))
checking whether to include arithmetic encoding support... yes
checking whether to include arithmetic decoding support... yes
checking whether to use 12-bit samples... no
checking whether to build TurboJPEG C wrapper... yes
checking whether to build TurboJPEG Java wrapper... no
checking if we have SIMD optimisations for cpu type... yes (arm)
checking if the assembler is GNU-compatible and can be used... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating pkgscripts/libjpeg-turbo.spec.tmpl
config.status: creating pkgscripts/makecygwinpkg.tmpl
config.status: creating pkgscripts/makedpkg.tmpl
config.status: creating pkgscripts/makemacpkg.tmpl
config.status: creating pkgscripts/uninstall.tmpl
config.status: creating pkgscripts/libjpeg.pc
config.status: creating pkgscripts/libturbojpeg.pc
config.status: creating tjbenchtest
config.status: creating libjpeg.map
config.status: creating Makefile
config.status: creating simd/Makefile
config.status: creating java/Makefile
config.status: creating md5/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: creating jconfig.h
config.status: jconfig.h is unchanged
config.status: creating jconfigint.h
config.status: jconfigint.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
make  all-recursive
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Making all in java
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making all in simd
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  all-am
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making all in md5
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
  CC       jmemmgr.lo
jmemmgr.c: In function 'realize_virt_arrays':
jmemmgr.c:659:11: error: 'SIZE_MAX' undeclared (first use in this function)
       if (SIZE_MAX - maximum_space < new_space)
           ^
jmemmgr.c:659:11: note: each undeclared identifier is reported only once for each function it appears in
Makefile:1170: recipe for target 'jmemmgr.lo' failed
make[2]: *** [jmemmgr.lo] Error 1
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Makefile:2031: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Makefile:790: recipe for target 'all' failed
make: *** [all] Error 2
Making install in java
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making install in simd
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  install-am
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making install in md5
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
  CC       jmemmgr.lo
jmemmgr.c: In function 'realize_virt_arrays':
jmemmgr.c:659:11: error: 'SIZE_MAX' undeclared (first use in this function)
       if (SIZE_MAX - maximum_space < new_space)
           ^
jmemmgr.c:659:11: note: each undeclared identifier is reported only once for each function it appears in
Makefile:1170: recipe for target 'jmemmgr.lo' failed
make[1]: *** [jmemmgr.lo] Error 1
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Makefile:2031: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1
bindesh@bindesh-Satellite-C650D:/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1$ sh AndroidBuild.sh 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-androideabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking how to run the C preprocessor... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
checking for arm-linux-androideabi-gcc... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... (cached) yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... (cached) none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... (cached) yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... (cached) gcc3
checking for arm-linux-androideabi-ar... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking the archiver (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar) interface... ar
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
checking if the linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm
checking the name lister (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to arm-unknown-linux-androideabi format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld option to reload object files... -r
checking for arm-linux-androideabi-objdump... no
checking for objdump... objdump
configure: WARNING: using cross tools not prefixed with host triplet
checking how to recognize dependent libraries... pass_all
checking for arm-linux-androideabi-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-androideabi-ar... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking for archiver @FILE support... @
checking for arm-linux-androideabi-strip... strip
checking for arm-linux-androideabi-ranlib... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib
checking command to parse /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm output from /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc object... ok
checking for sysroot... /home/bindesh/bin/ndk//platforms/android-9/arch-arm
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-linux-androideabi-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -fno-rtti -fno-exceptions... no
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to produce PIC... -fPIC -DPIC
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc PIC flag -fPIC -DPIC works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc static flag -static works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... (cached) yes
checking whether the /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes
checking dynamic linker characteristics... Android linker
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether ln -s works... yes
checking for arm-linux-androideabi-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking size of size_t... 4
checking whether compiler supports pointers to undefined structures... yes
checking whether __SUNPRO_C is declared... no
checking for ANSI C header files... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for string.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether char is unsigned... yes
checking for inline... inline
checking for size_t... yes
checking for unsigned char... yes
checking for unsigned short... yes
checking if right shift is signed... Assuming that right shift is signed on target machine.
checking for memset... yes
checking for memcpy... yes
checking libjpeg API version... 6.2
checking whether to include in-memory source/destination managers... yes
checking libjpeg shared library version... 62.2.0
checking whether the linker supports version scripts... yes (GNU style)
checking whether to use version script when building libjpeg-turbo... yes
checking for inline... inline __attribute__((always_inline))
checking whether to include arithmetic encoding support... yes
checking whether to include arithmetic decoding support... yes
checking whether to use 12-bit samples... no
checking whether to build TurboJPEG C wrapper... yes
checking whether to build TurboJPEG Java wrapper... no
checking if we have SIMD optimisations for cpu type... yes (arm)
checking if the assembler is GNU-compatible and can be used... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating pkgscripts/libjpeg-turbo.spec.tmpl
config.status: creating pkgscripts/makecygwinpkg.tmpl
config.status: creating pkgscripts/makedpkg.tmpl
config.status: creating pkgscripts/makemacpkg.tmpl
config.status: creating pkgscripts/uninstall.tmpl
config.status: creating pkgscripts/libjpeg.pc
config.status: creating pkgscripts/libturbojpeg.pc
config.status: creating tjbenchtest
config.status: creating libjpeg.map
config.status: creating Makefile
config.status: creating simd/Makefile
config.status: creating java/Makefile
config.status: creating md5/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: creating jconfig.h
config.status: jconfig.h is unchanged
config.status: creating jconfigint.h
config.status: jconfigint.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
make  all-recursive
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Making all in java
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making all in simd
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  all-am
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making all in md5
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
  CC       jmemmgr.lo
  CC       jmemnobs.lo
  CC       jaricom.lo
  CC       jcarith.lo
  CC       jdarith.lo
  CCLD     libjpeg.la
  CC       libturbojpeg_la-jcapimin.lo
  CC       libturbojpeg_la-jcapistd.lo
  CC       libturbojpeg_la-jccoefct.lo
  CC       libturbojpeg_la-jccolor.lo
  CC       libturbojpeg_la-jcdctmgr.lo
  CC       libturbojpeg_la-jchuff.lo
  CC       libturbojpeg_la-jcinit.lo
  CC       libturbojpeg_la-jcmainct.lo
  CC       libturbojpeg_la-jcmarker.lo
  CC       libturbojpeg_la-jcmaster.lo
  CC       libturbojpeg_la-jcomapi.lo
  CC       libturbojpeg_la-jcparam.lo
  CC       libturbojpeg_la-jcphuff.lo
  CC       libturbojpeg_la-jcprepct.lo
  CC       libturbojpeg_la-jcsample.lo
  CC       libturbojpeg_la-jctrans.lo
  CC       libturbojpeg_la-jdapimin.lo
  CC       libturbojpeg_la-jdapistd.lo
  CC       libturbojpeg_la-jdatadst.lo
  CC       libturbojpeg_la-jdatasrc.lo
  CC       libturbojpeg_la-jdcoefct.lo
  CC       libturbojpeg_la-jdcolor.lo
  CC       libturbojpeg_la-jddctmgr.lo
  CC       libturbojpeg_la-jdhuff.lo
  CC       libturbojpeg_la-jdinput.lo
  CC       libturbojpeg_la-jdmainct.lo
  CC       libturbojpeg_la-jdmarker.lo
  CC       libturbojpeg_la-jdmaster.lo
  CC       libturbojpeg_la-jdmerge.lo
  CC       libturbojpeg_la-jdphuff.lo
  CC       libturbojpeg_la-jdpostct.lo
  CC       libturbojpeg_la-jdsample.lo
  CC       libturbojpeg_la-jdtrans.lo
  CC       libturbojpeg_la-jerror.lo
  CC       libturbojpeg_la-jfdctflt.lo
  CC       libturbojpeg_la-jfdctfst.lo
  CC       libturbojpeg_la-jfdctint.lo
  CC       libturbojpeg_la-jidctflt.lo
  CC       libturbojpeg_la-jidctfst.lo
  CC       libturbojpeg_la-jidctint.lo
  CC       libturbojpeg_la-jidctred.lo
  CC       libturbojpeg_la-jquant1.lo
  CC       libturbojpeg_la-jquant2.lo
  CC       libturbojpeg_la-jutils.lo
  CC       libturbojpeg_la-jmemmgr.lo
  CC       libturbojpeg_la-jmemnobs.lo
  CC       libturbojpeg_la-jaricom.lo
  CC       libturbojpeg_la-jcarith.lo
  CC       libturbojpeg_la-jdarith.lo
  CC       libturbojpeg_la-turbojpeg.lo
  CC       libturbojpeg_la-transupp.lo
  CC       libturbojpeg_la-jdatadst-tj.lo
  CC       libturbojpeg_la-jdatasrc-tj.lo
  CCLD     libturbojpeg.la
  CC       cjpeg-cdjpeg.o
  CC       cjpeg-cjpeg.o
  CC       cjpeg-rdgif.o
  CC       cjpeg-rdppm.o
  CC       cjpeg-rdswitch.o
  CC       cjpeg-rdbmp.o
  CC       cjpeg-rdtarga.o
  CCLD     cjpeg
  CC       djpeg-cdjpeg.o
  CC       djpeg-djpeg.o
  CC       djpeg-rdcolmap.o
  CC       djpeg-rdswitch.o
  CC       djpeg-wrgif.o
  CC       djpeg-wrppm.o
  CC       djpeg-wrbmp.o
  CC       djpeg-wrtarga.o
  CCLD     djpeg
  CC       jpegtran.o
  CC       rdswitch.o
  CC       cdjpeg.o
  CC       transupp.o
  CCLD     jpegtran
  CC       rdjpgcom.o
  CCLD     rdjpgcom
  CC       wrjpgcom.o
  CCLD     wrjpgcom
  CC       tjbench-tjbench.o
  CC       tjbench-bmp.o
  CC       tjbench-tjutil.o
  CC       tjbench-rdbmp.o
  CC       tjbench-rdppm.o
  CC       tjbench-wrbmp.o
  CC       tjbench-wrppm.o
  CCLD     tjbench
  CC       jcstest.o
  CCLD     jcstest
  CC       tjunittest.o
  CC       tjutil.o
  CCLD     tjunittest
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Making install in java
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making install in simd
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  install-am
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making install in md5
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libjpeg.la libturbojpeg.la '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib'
libtool: install: /usr/bin/install -c .libs/libjpeg.lai /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.la
libtool: install: /usr/bin/install -c .libs/libturbojpeg.lai /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.la
libtool: install: /usr/bin/install -c .libs/libjpeg.a /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.a
libtool: install: chmod 644 /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.a
libtool: install: /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.a
libtool: install: /usr/bin/install -c .libs/libturbojpeg.a /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.a
libtool: install: chmod 644 /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.a
libtool: install: /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.a
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c cjpeg djpeg jpegtran rdjpgcom wrjpgcom tjbench '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin'
libtool: install: /usr/bin/install -c cjpeg /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/cjpeg
libtool: install: /usr/bin/install -c djpeg /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/djpeg
libtool: install: /usr/bin/install -c jpegtran /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/jpegtran
libtool: install: /usr/bin/install -c rdjpgcom /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/rdjpgcom
libtool: install: /usr/bin/install -c wrjpgcom /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/wrjpgcom
libtool: install: /usr/bin/install -c tjbench /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/tjbench
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /usr/bin/install -c -m 644 README.ijg README.md libjpeg.txt structure.txt usage.txt wizard.txt LICENSE.md '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /usr/bin/install -c -m 644 example.c '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /usr/bin/install -c -m 644 jerror.h jmorecfg.h jpeglib.h turbojpeg.h '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/man/man1'
 /usr/bin/install -c -m 644 cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1 '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/man/man1'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /usr/bin/install -c -m 644 jconfig.h '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/pkgconfig'
 /usr/bin/install -c -m 644 pkgscripts/libjpeg.pc pkgscripts/libturbojpeg.pc '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/pkgconfig'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'





Thursday, March 9, 2017

JPG Image size reducer. How to reduce jpg to desired size without changing resolution on PC and Android?

When we click a photo it contains lot of colors which our eyes cannot differentiate. Higher colors means higher image size and with evolving camera chips images are getting bigger and bigger in size. There are many methods to reduce photo size. Lets look at some methods of reducing image size.


I recently backup my images on Google drive. The images were bigger in size and were in GBs in size which i reduced to ~700MB (deleted few repeated images). Among size reduction methods most of us reduce the image resolution i.e. number of pixels are reduced. For example Full HD images are reduced to qHD or 720p. But i didn't reduced the number of pixels but number of colors!


This is already a reduced image of size ~900KB. I captured this image in my garden in 2016 summer using my Nubia Z9 mini phone. Its already reduced in size to load faster on website.



Original: 942KB


 Half resolution: 711KB





Reduced Colors: 268KB



Looking at images its clear that reducing number of colors has greater size reduction than reducing resolution only. Do check the images by downloading them and zoom. Decide yourself which one is better!


Now coming to the tools used for size reduction. Without taking much time below are some tools to reduce size of jpg.

  • ImageMagick's convert tool. This s a commandline tool which can reduce jpg size to desired size. Example: convert -define jpeg:extent=500kb nubia_bks_camera.jpg out.jpg. This will reduce original image to ~500KB without changing resolution.
  • jpegoptim: this tool is same as imagemagick with desired jpg size.
  • IrfanView. This is a windows only GUI software which can reduce jpg files to desired size.

I have created my own Android app which can do above size reduction and is very easy to work with. Here is the link to my app Jpg Image Size Reducer: https://play.google.com/store/apps/details?id=org.greh.imagesizereducer. A quick usage example of this app is you share your selfie which is 2MB and want to reduce size quickly without editing the image. Share it with any image app and select jpg image size reducer and reduce to whatever % or KB and then share the copy to wherever you want!. It can also reduce many files in batch. Its also an image converter and can convert non-jpg files to jpg and reduce its size.



The software above reduce number of colors which reduces size of image even more than reducing size does. However Using both methods can give very small size images. Reducing total colors to few thousand or hundreds can be noticed easily by zooming. Another method to reduce image size is to change image mode to INDEXED from RGB. Indexed mode means all colors are collected at a place/table and index/position of a color from table is used. This can reduce size. However this is not always better.