Lisp HUG Maillist Archive

Manipulating and writing images

Hello list
    I need to plead for some help with the lw (windows) gp
functionality. I was writing a script to automate generation of
correctly sized images for my website at the weekend, it has to load
each image, create medium and thumbnail sized versions and write them
out to appropriate directories, nothing complicated. All the originals
are jpegs of about 2000x1000 in size although there are variations. At
this point I had to wrestle with the graphics ports api, a bit more
complex than really necessary I think but in the end I got
something. In pseudo code, for each image it does;

(let ((my-ext-image (gp:read-external-image an-image-path)))

    ;; later ...
    ;; I do the following twice, to two different ports with different scales

    (gp:draw-image port (gp:convert-external-image port my-ext-image) 0 0
        :transform (list scale 0 0 scale 0 0))

    ;; later ...
    ;; I do this twice also, once for each port, width and height I calculate myself

    (gp:write-external-image
        (gp:externalize-image port 
            (gp:make-image-from-port port 0 0 width height))
        output-image-path))

    Now, I have a couple of questions :)

    If the port is an output-pane the image appears correctly, I
actually use a pixmap-port in the code. In either case the image that
is written to disk is corrupted, it has various coloured lines
threaded through it.
    I note some mention of a way to get the bounds of an image after
is has been drawn and possibly transformed onto a port but I can't
seem to make this work. Is it available for images?
    I know nothing about image formats or colour management so I
expect I've just missed one of the various parameters to the image
manipulation functions, I hope someone has an idea

        thanks

            Andrew


Updated at: 2020-12-10 08:48 UTC