Jump to page: 1 2 3
Thread overview
Library for image editing and text insertion
Apr 26, 2022
Alexander Zhirov
Apr 26, 2022
Guillaume Piolat
Apr 26, 2022
Alexander Zhirov
Apr 26, 2022
Guillaume Piolat
Apr 26, 2022
Alexander Zhirov
Apr 26, 2022
Guillaume Piolat
Apr 26, 2022
rikki cattermole
Apr 26, 2022
Alexander Zhirov
Apr 26, 2022
rikki cattermole
Apr 26, 2022
Guillaume Piolat
Apr 26, 2022
rikki cattermole
Apr 26, 2022
Guillaume Piolat
Apr 26, 2022
rikki cattermole
Apr 26, 2022
Guillaume Piolat
Apr 26, 2022
rikki cattermole
Apr 26, 2022
Guillaume Piolat
Apr 26, 2022
H. S. Teoh
Apr 27, 2022
Adam Ruppe
Apr 27, 2022
Alexander Zhirov
Apr 27, 2022
Dennis
Apr 27, 2022
Alexander Zhirov
Apr 27, 2022
Alexander Zhirov
Apr 27, 2022
Bastiaan Veelo
Apr 27, 2022
Alexander Zhirov
Apr 27, 2022
Adam D Ruppe
Apr 27, 2022
Alexander Zhirov
Apr 27, 2022
Alexander Zhirov
Apr 27, 2022
matheus
Apr 27, 2022
Alexander Zhirov
Apr 27, 2022
Adam D Ruppe
April 26, 2022

It is necessary to write a utility that will insert (x,y) text on the image. It is desirable that the utility does not depend on large libraries, since a minimum utility size is required. I'm looking for something similar in C/C++, I can't find anything. Maybe there is some simple library on D?

April 26, 2022

On Tuesday, 26 April 2022 at 17:22:54 UTC, Alexander Zhirov wrote:

>

It is necessary to write a utility that will insert (x,y) text on the image. It is desirable that the utility does not depend on large libraries, since a minimum utility size is required. I'm looking for something similar in C/C++, I can't find anything. Maybe there is some simple library on D?

You can eventually use dplug:graphics for that
https://u.pcloud.link/publink/show?code=XZPwMFVZW9c6bTWtevRvNz7UdfOOqVYIE5uk

April 26, 2022
On Tue, Apr 26, 2022 at 05:22:54PM +0000, Alexander Zhirov via Digitalmars-d-learn wrote:
> It is necessary to write a utility that will insert (x,y) text on the image.  It is desirable that the utility does not depend on large libraries, since a minimum utility size is required. I'm looking for something similar in C/C++, I can't find anything. Maybe there is some simple library on D?

Maybe use imagemagick?

	https://stackoverflow.com/questions/23236898/add-text-on-image-at-specific-point-using-imagemagick

Handling multiple image formats is generally a complex task that requires multiple libraries, some of which may not be trivial.  Unless you have a specific image format in mind?

Also, text rendering, in general, is an extremely complex and hairy problem.  At the very minimum, you need a font.  If you have a bitmap font, then it's relatively easy (just blit the characters you need onto the image with alpha blending).  But if you're looking at TTF fonts or similar, you're looking at the very minimum at using libfreetype to be able to meaningfully use the font file.  Then there's the issue of font layout, which is language-specific and may require a complex layout engine like HarfBuzz (which requires libraries with complex dependencies).

If utility size is of utmost importance, then the ideal case would be a fixed image format (so only 1 library is needed to process files of that type) with a bitmapped font (at worst, a 2nd library for reading the font) for a specific language (so no cross-language layout issues that requires complex layout engines). Then you can just treat the font characters as bitmaps and alpha-blend them onto the image. Preferably, use a monospaced bitmap font so that you can just use a fixed grid for character placement, and not have to deal with complex font metrics, hinting, kerning, and all of that complex stuff.  For this, maybe look at Adam Ruppe's arsd library (https://github.com/adamdruppe/arsd) for some lightweight modules that read common image formats and do some primitive image manipulations.


T

-- 
People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird. -- D. Knuth
April 26, 2022

On Tuesday, 26 April 2022 at 18:12:55 UTC, Guillaume Piolat wrote:

>

You can eventually use dplug:graphics for that
https://u.pcloud.link/publink/show?code=XZPwMFVZW9c6bTWtevRvNz7UdfOOqVYIE5uk

Performing "debug" build using /usr/bin/dmd for x86_64.
intel-intrinsics 1.9.2: target for configuration "library" is up to date.
dplug:core 12.5.2: target for configuration "library" is up to date.
dplug:math 12.5.2: target for configuration "library" is up to date.
dplug:graphics 12.5.2: building configuration "library"...
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1972,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 7)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1973,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 6 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1974,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 5 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1975,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 4 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1976,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 3 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1977,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 2 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1978,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 1 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1979,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1981,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 7)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1982,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 6 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1983,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 5 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1984,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 4 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1985,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 3 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1986,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 2 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1987,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 1 & 1)` of type `int` to `ubyte`
/usr/bin/dmd failed with exit code 1.

It's strange, for some reason it's not building.

April 26, 2022

On Tuesday, 26 April 2022 at 20:26:42 UTC, Alexander Zhirov wrote:

>

build error

Curious as to what DMD you are using on what OS? It builds with 2.095.1 to 2.100-b1 here.

April 26, 2022

On Tuesday, 26 April 2022 at 20:37:28 UTC, Guillaume Piolat wrote:

>

Curious as to what DMD you are using on what OS? It builds with 2.095.1 to 2.100-b1 here.

DMD64 D Compiler v2.098.0
OS Solus Linux

April 26, 2022

On Tuesday, 26 April 2022 at 20:45:16 UTC, Alexander Zhirov wrote:

>

On Tuesday, 26 April 2022 at 20:37:28 UTC, Guillaume Piolat wrote:

>

Curious as to what DMD you are using on what OS? It builds with 2.095.1 to 2.100-b1 here.

DMD64 D Compiler v2.098.0
OS Solus Linux

Well I cannot reproduce your problem => https://imgur.com/a/HZvZWr2

Perhaps a DUB mismatch that would give different DIP flags.
DUB version 1.27.0, built on Oct 19 2021

Good luck.

April 27, 2022
To get the commands dub used, use -v.

$ dub build -v
April 26, 2022

On Tuesday, 26 April 2022 at 21:04:17 UTC, rikki cattermole wrote:

>

$ dub build -v

Using dub registry url 'https://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/alexander/.dub/packages/local-packages.json
Looking for local package map at /mnt/hdd_data/programming/d/write text on image/.dub/packages/local-packages.json
Note: Failed to determine version of package lol at .. Assuming ~master.
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/alexander/.dub/packages/local-packages.json
Looking for local package map at /mnt/hdd_data/programming/d/write text on image/.dub/packages/local-packages.json
  Found dependency dplug:graphics 12.5.2
    Found dependency intel-intrinsics 1.9.2
    Found dependency dplug:math 12.5.2
    Found dependency dplug:core 12.5.2
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/alexander/.dub/packages/local-packages.json
Looking for local package map at /mnt/hdd_data/programming/d/write text on image/.dub/packages/local-packages.json
  Found dependency dplug:graphics 12.5.2
    Found dependency intel-intrinsics 1.9.2
    Found dependency dplug:math 12.5.2
    Found dependency dplug:core 12.5.2
Generating using build
Configuring dependent lol, deps:"dplug:graphics"
  Configuring dependent dplug:graphics, deps:"dplug:core", "dplug:math", "intel-intrinsics"
    Configuring dependent dplug:core, deps:"intel-intrinsics"
      Configuring dependent intel-intrinsics, deps:
    Configuring dependent dplug:math, deps:"intel-intrinsics"
Performing "debug" build using /usr/bin/dmd for x86_64.
intel-intrinsics 1.9.2: target for configuration "library" is up to date.
Using existing build in /home/alexander/.dub/packages/intel-intrinsics-1.9.2/intel-intrinsics/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-67C75DB793DA1F77431FDBF6F478D1AC/.
Copying target from /home/alexander/.dub/packages/intel-intrinsics-1.9.2/intel-intrinsics/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-67C75DB793DA1F77431FDBF6F478D1AC/libintel-intrinsics.a to /home/alexander/.dub/packages/intel-intrinsics-1.9.2/intel-intrinsics
dplug:core 12.5.2: target for configuration "library" is up to date.
Using existing build in /home/alexander/.dub/packages/dplug-12.5.2/dplug/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-D8C57FD168AF1371806144D918242E73/.
Copying target from /home/alexander/.dub/packages/dplug-12.5.2/dplug/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-D8C57FD168AF1371806144D918242E73/libdplug_core.a to /home/alexander/.dub/packages/dplug-12.5.2/dplug
dplug:math 12.5.2: target for configuration "library" is up to date.
Using existing build in /home/alexander/.dub/packages/dplug-12.5.2/dplug/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-331F3B3983F69B80C64AABFDF7D43329/.
Copying target from /home/alexander/.dub/packages/dplug-12.5.2/dplug/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-331F3B3983F69B80C64AABFDF7D43329/libdplug_math.a to /home/alexander/.dub/packages/dplug-12.5.2/dplug
Target '/home/alexander/.dub/packages/dplug-12.5.2/dplug/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-566711123C5A86FF62721CA5E0A67A56/libdplug_graphics.a' doesn't exist, need rebuild.
dplug:graphics 12.5.2: building configuration "library"...
/usr/bin/dmd -lib -of/home/alexander/.dub/packages/dplug-12.5.2/dplug/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-566711123C5A86FF62721CA5E0A67A56/libdplug_graphics.a -debug -g -w -version=Have_dplug_graphics -version=Have_dplug_core -version=Have_dplug_math -version=Have_intel_intrinsics -I/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics -I/home/alexander/.dub/packages/dplug-12.5.2/dplug/core -I/home/alexander/.dub/packages/intel-intrinsics-1.9.2/intel-intrinsics/source -I/home/alexander/.dub/packages/dplug-12.5.2/dplug/math /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/color.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/draw.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/drawex.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/font.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/image.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/jpegload.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/mipmap.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/package.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/resizer.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/stb_image_resize.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/stb_image_write.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/stb_truetype.d /home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/view.d -vcolumns
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1972,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 7)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1973,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 6 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1974,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 5 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1975,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 4 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1976,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 3 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1977,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 2 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1978,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 1 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1979,34): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1981,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 7)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1982,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 6 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1983,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 5 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1984,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 4 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1985,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 3 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1986,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 2 & 1)` of type `int` to `ubyte`
/home/alexander/.dub/packages/dplug-12.5.2/dplug/graphics/dplug/graphics/pngload.d(1987,41): Error: cannot implicitly convert expression `cast(int)scale * (cast(int)*in_ >> 1 & 1)` of type `int` to `ubyte`
FAIL /home/alexander/.dub/packages/dplug-12.5.2/dplug/.dub/build/library-debug-linux.posix-x86_64-dmd_v2.098.0-566711123C5A86FF62721CA5E0A67A56/ dplug_graphics staticLibrary
/usr/bin/dmd failed with exit code 1.
April 27, 2022
No args added there.

https://github.com/AuburnSounds/Dplug/blob/master/graphics/dplug/graphics/pngload.d#L1972

Yup that code certainly looks wrong.

Note the casts above it in around:
https://github.com/AuburnSounds/Dplug/blob/master/graphics/dplug/graphics/pngload.d#L1956

So yeah upstream issue.
« First   ‹ Prev
1 2 3