NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.37k stars 13.6k forks source link

imagemagic "label" option doesn't produce text #337834

Open rypervenche opened 2 weeks ago

rypervenche commented 2 weeks ago

Describe the bug

Using label with the magick command does not produce any text in the output image. I have tested this on a Gentoo machine that has version 7.1.1-25 and it works there. Does not work in 24.05 or unstable versions of imagemagick.

Steps To Reproduce

Steps to reproduce the behavior:

  1. magick label:"Test" output.png
  2. View output.png in any image viewer.

Expected behavior

output.png should be a white image with black text that says "Test".

Screenshots

2024-08-27_20-31

Additional context

Searching through other bug reports I saw something that made me think that perhaps imagemagick wasn't packaged properly to allow this to work, something like #82749

Notify maintainers

@erictapen @dotlambda @rhendric

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.47, NixOS, 24.05 (Uakari), 24.05.20240824.2527da1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixos-24.05, nixos-unstable"`
 - nixpkgs: `/nix/store/h95427cj0sswxq6k6v9qhhwnimgnhwhp-source`

Add a :+1: reaction to issues you find important.

erictapen commented 2 weeks ago

Interesting, as I can't reproduce on my NixOS 24.05 machine. You definetely should get at least an error message.

What is your NixOS fonts.* configuration?

Running your command in a Nix sandbox fails btw, probably due to a missing /etc/fonts. Not sure wether that behaviour is acceptable or not, but it seems to be different from your problem.

Fontconfig error: Cannot load default config file: No such file: (null)
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
Fontconfig error: No writable cache directories
magick: unable to read font `' @ error/annotate.c/RenderFreetype/1654.
rypervenche commented 1 week ago

I had the following:

fonts.packages = with pkgs; [
  noto-fonts
  noto-fonts-cjk
  noto-fonts-emoji
  liberation_ttf
  sarasa-gothic
];

I followed the fonts page on wiki.nixos.org and changed it to this, however it did not fix it.

fonts = {
  enableDefaultPackages = true;
  packages = with pkgs; [
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    liberation_ttf
    sarasa-gothic
  ];
  fontconfig = {
    defaultFonts = {
      serif = [ "DejaVu Sans" "Sarasa Gothic TC" ];
      sansSerif = [ "DejaVu Serif" "Sarasa Gothic TC" ];
      monospace = [ "DejaVu Sans Mono" "Sarasa Mono TC" ];
    };
  };
};

Here is the output of: magick -debug "All" label:"Test" output.png magick-debug.log

Please let me know if there is any other information that I can provide you with to help with this. Thanks.