WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: PicFormat extension submitted  (Read 3528 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10210
PicFormat extension submitted
« on: March 27, 2021, 09:22:20 PM »
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Quote
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:
https://www.linuxsecrets.com/tinycorelinux-wiki/wiki:creating_extensions.html#submitting
Use the  tcesubmit  email address, not the  picoresubmit  address.
« Last Edit: July 16, 2021, 09:21:48 PM by Rich »

Offline rullolex

  • Full Member
  • ***
  • Posts: 134
    • Rullolex
Re: PicFormat extension submitted
« Reply #1 on: March 28, 2021, 07:36:41 AM »
Hi Rich,

I'm interested to use PicFormat, looking via Apps browser I do not find it. (TC12)

Where I can download it?

Thanks

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10210
Re: PicFormat extension submitted
« Reply #2 on: March 28, 2021, 07:46:02 AM »
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:
Code: [Select]
tce-load -wi PicFormat

Offline rullolex

  • Full Member
  • ***
  • Posts: 134
    • Rullolex
Re: PicFormat extension submitted
« Reply #3 on: March 28, 2021, 08:07:13 AM »
Hi Rich,

Downloaded and loaded.

I confirm that PicFormat works with TC12 x86.

Ps.:sorry I forgot the time zone.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10210
Re: PicFormat extension submitted
« Reply #4 on: March 28, 2021, 08:10:59 AM »
Hi rullolex
... I confirm that PicFormat works with TC12 x86. ...
Thank you for testing.

Offline rullolex

  • Full Member
  • ***
  • Posts: 134
    • Rullolex
Re: PicFormat extension submitted
« Reply #5 on: March 28, 2021, 08:21:26 AM »
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


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10210
Re: PicFormat extension submitted
« Reply #6 on: March 28, 2021, 08:26:15 AM »
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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10210
Re: PicFormat extension submitted
« Reply #7 on: March 28, 2021, 08:39:00 AM »
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
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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$

Offline rullolex

  • Full Member
  • ***
  • Posts: 134
    • Rullolex
Re: PicFormat extension submitted
« Reply #8 on: March 28, 2021, 09:03:49 AM »
Hi Rich,
I have write 640*430 to semplify, I made this:

Code: [Select]
tc@box:~$ PicFormat -i /home/tc/Download/BACCANERA.jpg -o /home/tc/baccanera.jpg -w640
as your instruction. I'm sorry for the misunderstunding.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10210
Re: PicFormat extension submitted
« Reply #9 on: March 28, 2021, 09:14:30 AM »
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.

Offline rullolex

  • Full Member
  • ***
  • Posts: 134
    • Rullolex
Re: PicFormat extension submitted
« Reply #10 on: March 28, 2021, 09:32:21 AM »
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

Offline rullolex

  • Full Member
  • ***
  • Posts: 134
    • Rullolex
Re: PicFormat extension submitted
« Reply #11 on: April 18, 2021, 11:23:58 AM »
Hi to everyone,

I find PicFormat very useful it is possible to port it to Linux Mint?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 10210
Re: PicFormat extension submitted
« Reply #12 on: April 18, 2021, 02:06:25 PM »
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.

Offline rullolex

  • Full Member
  • ***
  • Posts: 134
    • Rullolex
Re: PicFormat extension submitted
« Reply #13 on: April 19, 2021, 01:33:14 PM »
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

Offline pioj

  • Jr. Member
  • **
  • Posts: 74
Re: PicFormat extension submitted
« Reply #14 on: July 16, 2021, 09:21:04 AM »
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.