Coder Social home page Coder Social logo

halftone's People

Contributors

albanobattistella avatar daudix avatar jose1711 avatar maryjaneinchain avatar mylesgit avatar penfore avatar scrambled777 avatar tfuxu avatar tiagoflach avatar twlvnn avatar vistaus avatar yakushabb avatar

Stargazers

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

Watchers

 avatar  avatar

halftone's Issues

Implement zoom for previews

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

Implement halftoning

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:

half1

And for the CMYK halftone:

helf2

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 :)

Failed to locate ?ui/dither_page.ui? in any source directory

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

Contrast controls

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.

1:1 preview

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:

  • when hovering the preview, display a square over the mouse cursor with the 1:1 preview
  • adding zoom controls to the preview (+/- buttons, mousewheel, etc.)

Sliders instead of spin rows

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.

From the HIG:

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

Implement image options retention

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.

No preview on a specific image

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

image
sample

Making it impossible to open unsupported formats

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.

Less disruptive loading of changes

When a change is made currently, the entire image preview is replaced with a spinner. This feels quite disruptive when done often.

Potential solutions:

  • Try making the changes load fast enough for a loading screen to become unnecessary
  • Overlay the spinner on top of the current image while the next iteration is loading

Image preview far too large

The image preview is far too large, resulting in ridiculous amounts of scrolling when using large images and shrinked small images.

Skärmbild från 2023-11-17 22-54-26

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

Better appdata summary

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"?

Bayer dither doesn't respect color amount

Noticed that ordered dither uses same color amount no matter how high you set it, comparing with Pixfect (ditherer.sh) it looks quite different (same 128 px | 10 colors)

halftone-bay-bridge

bay-bridge-ditherer

Apply to GNOME Circle

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:

Remove temporary previews on exception

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.

Drop ImageMagick in favor of PIL

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.

Footnotes

  1. Pillow Performance site

Appropriate color scheme

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.

0.5.0: Build fails: Failed to locate “ui/dither_page.ui” in any source directory.

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

Button for displaying previews in external image viewers

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.

Example:

image

Facing no delegate module error while snapping this app

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

Reconsidering "keep aspect ratio" and "image height" settings

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 😄

Reduce minimal width to 360px for mobile support

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:

Without any tweaks

And here in it's current form with scale-to-fit

With scale-to-fit

Menu with scale-to-fit

I am happy to help with testing, unfortunately (day job) it may take me a bit to give proper feedback.

How to translate Halftone

This is a tutorial for those who want to contribute to Halftone by adding translations.

  1. Grab any available translation editor which supports GNU Gettext format (I recommend Poedit)
  2. Follow project's contribution guide, from step 1 to 4
  3. Open your translation editor of choice, and create new translation from .pot template located in po/halftone.pot
  4. After finishing up translation, continue following contribution guide through step 6 to 8

Renaming Pixely to Halftone

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.

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.