Tiny Core Linux
Tiny Core Extensions => TCE News => Topic started by: Rich on March 28, 2021, 12:22:20 AM
-
I recently wanted to reduce some pictures prior to emailing them from 3264 x 2448 to 800 x 600. Looking in the
repository I only found ImageMagick and GraphicsMagick, both of which were a lot more than I was looking for. I just
wanted a small simple command line utility that doesn't require X, so I wrote one. Its only dependency is imlib2.tcz.
If you are running Xorg or Xvesa then imlib2.tcz is already installed.
PicFormat is about 4600 bytes. Running it with no parameters produces this help screen:
PicFormat version 0.10 Mar 27 2021 17:03:29
Copyright Richard A. Rost Mar 17,2021
PicFormat performs simple image manipulation such as
resizing, rotating, and format change (i.e. .jpg to .png).
Usage: PicFormat [-i FILE] [-o FILE] [-w N] [-h N] [-r N]
-i FILE Input image.
-o FILE Output image.
-w N Output width in pixels.
-h N Output height in pixels.
-r N Rotate image CW 90, 180, or 270 degrees.
Notes
Only -w OR -h is needed if resizing.
If rotating 90 or 270, -w and -h are swapped.
imlib2 does not provide a mechanism to list which image formats it can load or save. I wrote a small script to list them:
tc@E310:~/C_Programs/PicFormat$ ./PicFormats.sh
argb.so load save
bmp.so load save
bz2.so load
ff.so load save
gif.so load
jpeg.so load save
lbm.so load
png.so load save
pnm.so load save
tga.so load save
tiff.so load save
xpm.so load
zlib.so load
tc@E310:~/C_Programs/PicFormat$
It requires one of these optional dependencies, binutils.tcz or elfutils.tcz.
The x86 and x86_64 versions were built under TC10. The x86 executable was also tested under TC4. The x86_64
executable was also tested under TC11. In addition, since imlib2 is unchanged in TC10 through TC12, I feel confident
PicFormat will run under all those versions and has been added to those repositories.
If someone wants to build it for piCore, piCore 11 and piCore 12 both have imlib2 available. The source package is here:
http://tinycorelinux.net/10.x/x86/tcz/src/PicFormat/
To build it:
tar xf PicFormat-source-v0.20.tar.gz
cd PicFormat
./CompilePicFormat
When it completes, copy PicFormat.tcz, PicFormat.tcz.dep, and PicFormat.tcz.md5.txt to your tce/optional directory. Then:
tce-load -i PicFormat
You will also find a PicFormat-armv.tar.gz.bfe or PicFormat-aarch64.tar.gz.bfe file has been created. It contains
all the extension files and a source package.
Now you can submit it to the repository. Attach the PicFormat file with the .bfe extension it to a brief email that says:
Attached is PicFormat for TC12.
PicFormat-armv.tar.gz.bfe contains the extension and the source tarball.
Adjust the TC version and filename as required.
The instructions for emailing the extension are here:
http://wiki.tinycorelinux.net/doku.php?id=wiki:creating_extensions#submitting
Use the tcesubmit email address, not the picoresubmit address.
-
Hi Rich,
I'm interested to use PicFormat, looking via Apps browser I do not find it. (TC12)
Where I can download it?
Thanks
-
Hi rullolex
It is present in both TC 12 repositories:
http://tinycorelinux.net/12.x/x86/tcz/PicFormat.tcz.info
http://tinycorelinux.net/12.x/x86_64/tcz/PicFormat.tcz.info
What happens if you execute this:
tce-load -wi PicFormat
-
Hi Rich,
Downloaded and loaded.
I confirm that PicFormat works with TC12 x86.
Ps.:sorry I forgot the time zone.
-
Hi rullolex
... I confirm that PicFormat works with TC12 x86. ...
Thank you for testing.
-
Hi rullolex
... I confirm that PicFormat works with TC12 x86. ...
Thank you for testing.
you are welcome, I scale a jpg 4500x3000 to a 640x430 jpg, I will try other formats and I will report
-
Anyone wishing to use PicFormat in an x86 command line only environment, make sure your imlib2.tcz.dep file
is up to date. See:
http://forum.tinycorelinux.net/index.php/topic,24901.0.html
-
Hi rullolex
... I scale a jpg 4500x3000 to a 640x430 jpg, ...
You are aware you changed the aspect ratio from 1.5:1 to 1.48837:1
tc@box:~$ calc 4500/3000
1.5
tc@box:~$ calc 640/430
1.48837
tc@box:~$
If you only provide -w or -h the program will calculate the other value based on the aspect ratio of the input file.
For example:
tc@E310:~/C_Programs/PicFormat$ ./PicFormat -i ShackleWrench12.png -w 1600 -o ShackleWrench12.jpg
Input=ShackleWrench12.png Fmt=png W=800 H=600 AR=4:3
Output=ShackleWrench12.jpg Fmt=jpg W=1600 H=1200 AR=4:3 Rotate=0
tc@E310:~/C_Programs/PicFormat$
or:
tc@E310:~/C_Programs/PicFormat$ ./PicFormat -i ShackleWrench12.png -h 1200 -o ShackleWrench12.jpg
Input=ShackleWrench12.png Fmt=png W=800 H=600 AR=4:3
Output=ShackleWrench12.jpg Fmt=jpg W=1600 H=1200 AR=4:3 Rotate=0
tc@E310:~/C_Programs/PicFormat$
-
Hi Rich,
I have write 640*430 to semplify, I made this:
tc@box:~$ PicFormat -i /home/tc/Download/BACCANERA.jpg -o /home/tc/baccanera.jpg -w640
as your instruction. I'm sorry for the misunderstunding.
-
Hi rullolex
You are allowed to give both -w and -h if you want to. Just be aware, it will give you what you ask for.
If your input is 800*600 and you ask for 1600*600 your image will be stretched horizontally but keep its original height.
-
Hi Rich,
Hi rullolex
You are allowed to give both -w and -h if you want to. Just be aware, it will give you what you ask for.
If your input is 800*600 and you ask for 1600*600 your image will be stretched horizontally but keep its original height.
ok, I think it is better to give only one parameter to have a perfect scale
-
Hi to everyone,
I find PicFormat very useful it is possible to port it to Linux Mint?
-
Hi rullolex
It looks like Linux Mint uses .deb packages. I did a quick search and I got the impression it requires tools not
available in Tinycore. I'm afraid Tinycore is the only distro I run.
If someone wishes to port this to another distro, they are welcome to do so. They can either copy the executable(s) from
the extension or build from source. A complete source package can be found here:
http://tinycorelinux.net/10.x/x86/tcz/src/PicFormat/
It contains the source package and a build script. Sorry, I don't do make files. The build script should have
enough comments so it's not too difficult to follow.
-
Hi Rich,
thank you for you reply, I will copy the executable and see if it works.
I will download the source code and try to build it
Regards
-
May I suggest you to add an argument for % factor scale?
It may become quite useful when you're batch processing lots of files.
Thanx for the submit.
-
Hi pioj
Thanks for the suggestion. I will look into it.
-
Hi pioj
I added a -p N option. So -p 75 reduces the image to 3/4 of its original size, -p 100 keeps the same size, -p 110
makes it 10% larger, -p 200 makes it twice as big, etc.
The new executable is 4748 bytes in size. Running it with no parameters produces this help screen:
PicFormat version 0.20 Jul 16 2021 23:23:30
Copyright Richard A. Rost Mar 17,2021
PicFormat resizes, rotates, and changes formats (i.e. .jpg to .png)
Usage: PicFormat [-i FILE] [-o FILE] [-w N] [-h N] [-p N] [-r N]
-i FILE Input.
-o FILE Output.
-w N Output width.
-h N Output height.
-p N Percent, 110=10% bigger, 50=1/2 size.
-r N Rotate image CW 90, 180, or 270 degrees.
Notes
N is an unsigned integer.
Only -w OR -h OR -p is needed if resizing.
If rotating 90 or 270, -w and -h are swapped.
The .info file:
http://tinycorelinux.net/12.x/x86/tcz/PicFormat.tcz.info
To find out which image formats are supported, please read the original post:
http://forum.tinycorelinux.net/index.php/topic,24900.0.html
The x86 and x86_64 versions were built under TC10. The x86 executable was also tested under TC4. The x86_64
executable was also tested under TC11. In addition, since imlib2 is unchanged in TC10 through TC12, I feel confident
PicFormat will run under all those versions and has been added to those repositories.