Giter Site home page Giter Site logo

makejxl's Introduction

makejxl

This tool will bulk encode image files in given directory to JPEG-XL. It will leave original files intact, creating .jxl file next to each original.

JPEG-XL encoder is still under development, but format is frozen since 2020-12-24 and files encoded today will be readable by later versions of decoders.

You don't need to use this tool at all. Examples for Shell and PowerShell scripts are below.

Supported input file formats:

  • .jpeg/.jpg (conversion is lossless and reversible)
  • .exr
  • .gif
  • .pfm
  • .pgm/.ppm
  • .pgx
  • .png

Supports Windows, Linux, MacOS and probably other OSes.

Linux

pip install makejxl
makejxl --recursive /home/username/myphotos

You will need cjxl in path. You can get it by running build_cjxl.sh as root

Or simpler alternative that doesn't need this script:

apt install imagemagick parallel
find /path/to/images -type f -iregex '.*\(gif\|jpe?g\|png\)$' | parallel convert {} {.}.jxl

Windows

You can download and use it as single Windows binary, see Releases

Unfortunately antiviruses don't like packed Python executables, so expect false positives from them if you go this way. Best way is pip.

You will need cjxl in path. It's best to build it using this tool and copy to %USERPROFILE%\AppData\Local\Microsoft\WindowsApps

./makejxl.exe "c:\\Users\\username\\Pictures\\My Vacation"

Or simpler alternative that doesn't need this script:

cd c:\photos
Get-ChildItem -Path c:\temp\ -File -Include '*.jpg', '*.jpeg' -Name | Foreach {cjxl $_ $([io.path]::ChangeExtension($_, "jxl"))}

See also

TODO

  • Decoder mode

makejxl's People

Contributors

varnav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

makejxl's Issues

Command injection vulnerbility

The current code calls cjxl as a stitched-together shell command, and that's not safe: a filename with a semicolon in it would just create a second command.

You might ask about quoting, but the issue is the different default shells (cmd and sh) have different quoting methods.

I am on a phone right now, but the gist is to replace

convert_cmd = f'cjxl --quiet -s {speed} --num_threads={jobs} {fp} {newpath}'
conversion_return_code = run(convert_cmd, shell=True).returncode

with

convert_cmd = ['cjxl', '--quiet', '-s', speed, f'--num_threads={jobs}', fp, newpath]
conversion_return_code = run(convert_cmd).returncode

(It would be nice to add a '--', before fp so the program does not recognize a name starting with - as some invalid option, but i can't check if cjxl takes that yet.)

I am just trying to encode JPEG to JXL

Hello! I tried to follow these steps, but when I typed: makejxl.exe "c:\Users\username\Pictures\My Vacation" its example folder and I got a error:
cjxl not found
Traceback (most recent call last):
File "makejxl.py", line 86, in
main()
File "click\core.py", line 829, in call
File "click\core.py", line 782, in main
File "click\core.py", line 1066, in invoke
File "click\core.py", line 610, in invoke
File "makejxl.py", line 44, in main
exit(1)
NameError: name 'exit' is not defined
[30220] Failed to execute script makejxl

I already downloaded the cjxl, where do I put cjxl for path environment?
Please help me, @varnav !

Regards

  • Martin Eesmaa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.