tfuxu / halftone Goto Github PK
View Code? Open in Web Editor NEWGive your images that pixel art-like style
License: GNU General Public License v3.0
Give your images that pixel art-like style
License: GNU General Public License v3.0
This will require a custom image processing library that supports image tilling and a way to implement custom image viewer that is not based on Gtk.Picture
.
libvips looks like a good contender and it appears to support tilling (required to zoom on images without going OOM).
There is a complete image viewer made using vips
, which could be useful to see how the zoom is implemented here.
Disregard what's written above. This can be achieved by subclassing Gdk.Texture
. There are examples available in GTK4 Demo, Tuba and Extension Manager.
Related #11
Great app!
With this name and this logo however, I would expect to be able to use it for doing actual halftones (the print kind), and not dithering (the screen kind). So I suggest that halftoning could be added, even maybe as a default algorithm?
There might already be open source code for it that could be integrated?
For a quick implementation, I suggest the “Color Amount” option could have two choices, either “1” (in which case it would be doing a monochrome halftoning of the grayscale image), or “4” (in which case it would do overlayed CMYK halftones).
I don’t have anything than Photoshop underhand right now, but for reference, here are the options for the default monochrome halftone it has:
And for the CMYK halftone:
Ideally choosing angles, shape, colours and resolution would be amazing, but a simple implementation with default angles could work too at least for a start :)
Trying to build I am getting the following error:
ninja -C builddir install
ninja: Entering directory `builddir'
[1/2] Generating data/halftone_gresource with a custom command
FAILED: data/halftone.gresource
/usr/bin/glib-compile-resources ../data/halftone.gresource.xml --sourcedir /data/jose/tmp/Halftone/builddir/data --sourcedir data/ui --sourcedir ../data --internal --generate --target data/halftone.gresource --dependency-file data/halftone.gresource.d
../data/halftone.gresource.xml: Failed to locate ?ui/dither_page.ui? in any source directory.
ninja: build stopped: subcommand failed.
ArchLinux x86_64
When I'm creating my dithered images for my blog, I usually add more contrast (and adjust the brightness accordingly) before applying dithering and see how it turns out. Most of the time, I need to cancel the dithering and re-adjust contrast/brightness before re-applying. So in my usecase, it could be very useful to have such controls directly available in Halftone.
Create a simple CLI for interacting with backend functions of Haltone.
Would it be interesting to allow some way to see how the dithered image looks like in its actual size (apart for the solution proposed in #10?) I can think of two ways of implementing it:
The color amount, brightness and contrast settings are currently implemented as spin buttons, but they might make more sense as sliders. For the settings that can be both positive and negative, you can have a snapping point in the center and have the slider be set to 50% by default. See the sound panel in Settings for reference.
Use a slider when:
- the range of values is fixed and ordered
- adjusting the value relative to its current value is more important than choosing an absolute value
- it is useful for the user to control the rate of change of the value in real time
- the number of potential values is high
Currently when the second image is loaded into Halftone, sidebar still holds the same options used in the first image, but the options in backend are reset to default.
This means that no matter what was set by user, it is reset when he loads the second image. This might lead to confusion, so ideally it should be fixed before next release.
Using version 0.3.1 from Flatpak on Fedora Silverblue 38
The attached sample.png file (generated from a color image that I've desaturated using https://maoschanz.github.io/drawing/) does not display any preview when loaded in Halftone (see screenshot). I cannot reproduce this issue with other files from the same folder, so I don't think this is a sandboxing issue
I attempted to open an .avif file, and the app just hanged. The command line output indicated that it's unsupported. Since avif apparently doesn't work, it and other unsupported formats shouldn't be openable.
When a change is made currently, the entire image preview is replaced with a spinner. This feels quite disruptive when done often.
Potential solutions:
The image preview is far too large, resulting in ridiculous amounts of scrolling when using large images and shrinked small images.
In addition, the sidebar is awkward on small screen sizes. Is there a way to pull it up from the bottom (like the previous UI iteration) in order to be able to see the images at a smaller size? The new UI is very good at large screen sizes but does the above at small screen sizes, which is likely not wanted behavior.
Version: 0.4.0
The current summary "Give your images that pixel art-like style" is a bit longer than the recommended 35 character maximum. It's also not super informative, I feel like mentioning dithering would be good. How about something like "Dither your images", or "Apply dithering to images"?
I think that Halftone in it's current state (after merging #46) might be a good candidate for inclusion in GNOME Circle.
List of things to do before applying:
Currently if Halftone crashes or doesn't close properly, it just exits from main loop and doesn't do any cleaning. Instead, it should remove any remaining temporary preview files.
To do this, main loop (and threads) can be connected to the custom excepthook. More info here.
Pixely doesn't currently have an icon to represent itself. I've made a prototype of a symbolic icon to give a general idea how a full icon could look like.
Source SVG: https://github.com/tfuxu/Pixely/assets/73042332/128f7563-db8a-4a36-baba-f93c278f0994
Short description: It's a mish-mash of image-symbolic
, decode-symbolic
and checkerboard-symbolic
icons
Moving from Wand (wrapper for ImageMagick) to Pillow would allow me to utilize hitherdither (see the comment below) library, which contains additional dithering algorithms and custom image palettes. As an added bonus, the packaging will become probably more straightforward, and the performance will improve1.
Pillow Performance site ↩
Halftone currently uses the FORCE_DARK
color scheme. It would be better to use PREFER_DARK
here, so the app still becomes light when someone explicitly sets the system-wide color scheme preference to prefer-light
instead of default
. It's not currently exposed in GNOME, but might be in the future.
WARNING: Recommend using either -Dbuildtype or -Doptimization + -Ddebug. Using both is redundant since they override each other. See: https://mesonbuild.com/Builtin-options.html#build-type-options
The Meson build system
Version: 1.2.3
Source dir: /usr/ports/graphics/halftone/work/Halftone-0.5.0
Build dir: /usr/ports/graphics/halftone/work/Halftone-0.5.0/_build
Build type: native build
Project name: halftone
Project version: 0.5.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program git found: YES (/usr/local/bin/git)
Found pkg-config: /usr/local/bin/pkgconf (2.0.3)
Run-time dependency glib-2.0 found: YES 2.78.0
Run-time dependency gtk4 found: YES 4.12.3
Run-time dependency libadwaita-1 found: YES 1.4.0
Run-time dependency pygobject-3.0 found: YES 3.42.2
Program python3 found: YES (/usr/ports/graphics/halftone/work/.bin/python3)
Configuring halftone using configuration
Configuring constants.py using configuration
halftone/meson.build:13: WARNING: The variable(s) 'TRANSLATE_URL' in the input file 'halftone/constants.in' are not present in the given configuration data.
Program blueprint-compiler found: YES (/usr/local/bin/blueprint-compiler)
Configuring io.github.tfuxu.Halftone.desktop.in using configuration
Program msgfmt found: YES (/usr/local/bin/msgfmt)
Program desktop-file-validate found: YES (/usr/local/bin/desktop-file-validate)
Found pkg-config: /usr/local/bin/pkgconf (2.0.3)
Build-time dependency gio-2.0 found: YES 2.78.0
Program /usr/local/bin/glib-compile-resources found: YES (/usr/local/bin/glib-compile-resources)
Configuring io.github.tfuxu.Halftone.appdata.xml.in using configuration
data/meson.build:39: WARNING: The variable(s) 'TRANSLATE_URL' in the input file 'data/io.github.tfuxu.Halftone.appdata.xml.in.in' are not present in the given configuration data.
Program appstream-util found: NO
Configuring io.github.tfuxu.Halftone.gschema.xml using configuration
Program glib-compile-schemas found: YES (/usr/local/bin/glib-compile-schemas)
Program msginit found: YES (/usr/local/bin/msginit)
Program msgmerge found: YES (/usr/local/bin/msgmerge)
Program xgettext found: YES (/usr/local/bin/xgettext)
Dependency gio-2.0 found: YES 2.78.0 (cached)
Program /usr/local/bin/glib-compile-schemas found: YES (/usr/local/bin/glib-compile-schemas)
Program gtk4-update-icon-cache found: YES (/usr/local/bin/gtk4-update-icon-cache)
Program update-desktop-database found: YES (/usr/local/bin/update-desktop-database)
Build targets in project: 17
halftone 0.5.0
User defined options
auto_features : enabled
buildtype : release
infodir : share/info
mandir : man
optimization : plain
prefix : /usr/local
strip : True
python.bytecompile: -1
b_colorout : never
Found ninja-1.11.1 at /usr/local/bin/ninja
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
===> Building for halftone-0.5.0
[ 7% 7/13] /usr/local/bin/msgfmt -o po/it/LC_MESSAGES/halftone.mo ../po/it.po
[ 15% 8/13] /usr/local/bin/msgfmt -o po/pt_BR/LC_MESSAGES/halftone.mo ../po/pt_BR.po
[ 23% 9/13] /usr/local/bin/msgfmt -o po/nl/LC_MESSAGES/halftone.mo ../po/nl.po
[ 30% 10/13] /usr/local/bin/msgfmt -o po/pl/LC_MESSAGES/halftone.mo ../po/pl.po
[ 38% 11/13] /usr/local/bin/msgfmt -o po/sk/LC_MESSAGES/halftone.mo ../po/sk.po
[ 46% 12/13] /usr/local/bin/msgfmt -o po/ru/LC_MESSAGES/halftone.mo ../po/ru.po
[ 53% 12/13] /usr/local/bin/msgfmt -o po/tr/LC_MESSAGES/halftone.mo ../po/tr.po
[ 61% 12/13] /usr/local/bin/msgfmt -o po/uk/LC_MESSAGES/halftone.mo ../po/uk.po
[ 69% 12/13] /usr/local/bin/msgfmt -o po/zh_CN/LC_MESSAGES/halftone.mo ../po/zh_CN.po
[ 76% 12/13] /usr/local/bin/meson --internal msgfmthelper --msgfmt=/usr/local/bin/msgfmt data/io.github.tfuxu.Halftone.desktop.in data/io.github.tfuxu.Halftone.desktop desktop ../data/../po
[ 84% 12/13] /usr/local/bin/meson --internal msgfmthelper --msgfmt=/usr/local/bin/msgfmt data/io.github.tfuxu.Halftone.appdata.xml.in data/io.github.tfuxu.Halftone.appdata.xml xml ../data/../po
[ 92% 12/13] /usr/local/bin/blueprint-compiler batch-compile data/ui/. ../data/ui ../data/ui/dither_page.blp ../data/ui/help_overlay.blp ../data/ui/main_window.blp ../data/ui/preferences_window.blp ../data/ui/report_page.blp
usage: blueprint-compiler [-h] [--version] command ...
positional arguments:
command
compile Compile blueprint files
batch-compile
Compile many blueprint files at once
port Interactive porting tool
lsp Run the language server (for internal use by IDEs)
help Show this message
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
[100% 13/13] /usr/local/bin/glib-compile-resources ../data/halftone.gresource.xml --sourcedir /usr/ports/graphics/halftone/work/Halftone-0.5.0/_build/data --sourcedir data/ui --sourcedir ../data --internal --generate --target data/halftone.gresource --dependency-file data/halftone.gresource.d
FAILED: data/halftone.gresource
/usr/local/bin/glib-compile-resources ../data/halftone.gresource.xml --sourcedir /usr/ports/graphics/halftone/work/Halftone-0.5.0/_build/data --sourcedir data/ui --sourcedir ../data --internal --generate --target data/halftone.gresource --dependency-file data/halftone.gresource.d
../data/halftone.gresource.xml: Failed to locate “ui/dither_page.ui” in any source directory.
ninja: build stopped: subcommand failed.
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1
blueprint-compiler-0.10.0
FreeBSD 13.2
A button for displaying preview image in image viewer would be quite useful if a user would want to examine a picture in full resolution before saving it.
Implementing such a button would require a couple of changes to how previews are currently stored, as of now they are stored directly in RAM (which is probably a cause of high memory usage after changing options in app for some time with high-res image loaded), the idea would be to just store previews in /tmp
directory, so that they could be easily accessible by external image viewers.
For where I would put the button in UI, to not make window unnecessary taller, I would put a button as a overlay on preview widget itself, like how Damask does it on downloaded wallpapers preview.
Hii, I have been trying to snap this app. The GUI shows up, but, whenever I add any kind of image file, I face this error.
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/snap/halftone/current/usr/share/halftone/halftone/utils/killable_thread.py", line 27, in _run
self._run_backup()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/snap/halftone/current/usr/share/halftone/halftone/views/dither_page.py", line 139, in update_preview_image
self.preview_image_path = HalftoneImageMagick().dither_image(path, self.output_options)
File "/snap/halftone/current/usr/share/halftone/halftone/backend/magick.py", line 21, in dither_image
with Image(filename=path) as img:
File "/snap/halftone/x15/usr/lib/python3.10/dist-packages/wand/image.py", line 9365, in __init__
self.read(filename=filename)
File "/snap/halftone/x15/usr/lib/python3.10/dist-packages/wand/image.py", line 10120, in read
self.raise_exception()
File "/snap/halftone/x15/usr/lib/python3.10/dist-packages/wand/resource.py", line 225, in raise_exception
raise e
wand.exceptions.MissingDelegateError: NoDecodeDelegateForThisImageFormat `PNG' @ error/constitute.c/ReadImage/781
In the snap, magick is installed same way as it's done in flatpak. At first I facing the same issue but with 'JPG'
instead of 'PNG'
Later, I added
- --with-modules=yes
- --enable-delegate-build=yes
- --with-png=yes
But, now I am getting this error. But, the snap itself still have all the same files and libraries as the flatpak. Am I missing anything, or any ENVIRONMENT VARIABLE
is missing to point towards the magick libraries.
This is the snapcraft.yaml
for your help:
name: halftone # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
adopt-info: halftone
version: '0.2.0'
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots
parts:
magick:
plugin: autotools
source: https://github.com/ImageMagick/ImageMagick.git
source-commit: "920f79206ff59f30a4cff22c9c9c393508b82663"
autotools-configure-parameters:
- --prefix=/usr
- --with-heic=yes
- --with-rsvg=yes
- --with-modules=yes
- --enable-delegate-build=yes
- --with-png=yes
prime:
- -usr/lib/pkgconfig
- -usr/include
- -usr/share
halftone:
after: [ magick ]
# See 'snapcraft plugins'
plugin: meson
source: https://github.com/tfuxu/Halftone.git
source-tag: '0.3.0'
meson-parameters:
- --prefix=/snap/halftone/current/usr
- -Dbuildtype=release
override-pull: |
craftctl default
patch -p1 < $CRAFT_PROJECT_DIR/halftone.patch
pip install --prefix=$CRAFT_PART_INSTALL/usr Wand
build-packages:
- blueprint-compiler
- execstack
stage-packages:
- libjpeg62
override-build: |
craftctl default
mkdir -p $CRAFT_PART_INSTALL/meta/gui
cp -r $CRAFT_PART_INSTALL/snap/halftone/current/usr/share/icons $CRAFT_PART_INSTALL/meta/gui/
for i in `find $CRAFT_PART_INSTALL/meta/gui/icons -name "*.svg" -o -name "*.png"`; do
mv $i "`dirname $i`/snap.$CRAFT_PROJECT_NAME.`basename $i`"
done
override-prime: |
craftctl default
if [ "$CRAFT_ARCH_TRIPLET" = "arm-linux-gnueabihf" ]; then
execstack --clear-execstack usr/lib/arm-linux-gnueabihf/libde265.so.0.1.1
fi
parse-info: [usr/share/appdata/io.github.tfuxu.Halftone.appdata.xml]
organize:
snap/halftone/current: .
usr/local: usr
usr/lib/python3: usr/lib/python3.10
prime:
- -snap/halftone
slots:
halftone:
interface: dbus
bus: session
name: io.github.tfuxu.Halftone
apps:
halftone:
command: usr/bin/halftone
common-id: io.github.tfuxu.Halftone
extensions: [gnome]
environment:
PYTHONPATH: $SNAP/usr/lib/python3.10/dist-packages:$PYTHONPATH
MAGICK_HOME: $SNAP/usr
MAGICK_CODER_MODULE_PATH: $SNAP/usr/lib/
plugs:
- home
The separate height option in the image preferences only makes sense if people actually want a different aspect ratio from the original image, which I assume basically never happens. Is the preference worth the cost? Cutting away that and the "keep aspect ratio" preferences would make that section simpler 😄
"Open in External Image Viewer" button not working with Loupe nor the EoG, there are no logs apparently
Hi,
I have just tried your great app on the Librem 5 and it's working quite well (when applying the scale-to-fit "hack" that makes too wide apps fit the screen in Phosh) on mobile already, and I am really glad to see more work regarding mobile support in #44 !
360px would be the correct value due to 2x scaling on a 1440x720px screen (or 3x on 1080px wide screens when held in portrait)
See https://developer.gnome.org/hig/guidelines/adaptive.html for reference.
(BTW, if you have input to make https://linuxphoneapps.org/docs/resources/developer-information/ better, please get in touch :) )
Here's how the app looks as is:
And here in it's current form with scale-to-fit
I am happy to help with testing, unfortunately (day job) it may take me a bit to give proper feedback.
This is a tutorial for those who want to contribute to Halftone by adding translations.
.pot
template located in po/halftone.pot
Halftone is a image technique that makes use of dots varying in size and spacing to create a gradient-like effect on pictures. It's an analogous technique to dithering, but used in printing instead on computer screens. In my opinion it's a better name than Pixely, as it has direct correlation to (image) dithering.
Renaming will start today, there aren't thankfully any packages of Pixely distributed yet, so everything should be done very soon.
Currently bottom sheet just disappears when toggling its visibility. Instead, it should hide smoothly like a sidebar.
For that, Adw.SpringAnimation
could be used with Adw.SwipeTracker
for hide swipe gesture.
Reference: #246
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.