[racket] Generating svg-images rather than png-images from Scribble

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Oct 15 13:13:19 EDT 2013

On Tue, Oct 15, 2013 at 12:04 PM, Neil Toronto <neil.toronto at gmail.com>wrote:

> Are their PNG bytes base64-encoded in an image tag inside the SVG? Or is
> it something less smart?
>
>
They are currently in separate files


> Maybe the right thing to do is have each kind of convertible thing be able
> to specify its most natural encoding.
>
>
In this particular case (with the big files) the specification of what the
values can convert to is inside the library and the decision about what
this particular one should convert to is outside the library.

But, putting 2+2 together with Jens Axel's other message, I can just
convert these ones to bitmaps behind the scenes and then have something
else in place that doesn't convert bitmaps.

Robby


> Neil ⊥
>
>
> On 10/15/2013 10:37 AM, Robby Findler wrote:
>
>> Oh, and another thought: it appears that the 2htdp/image documentation
>> just went from 4 megs to 15 megs (of space on the disk) with the change
>> to SVG. It looks like there are just two images that account for nearly
>> 10 megs, tho. So I could switch just those back to being pngs and that
>> would make a big difference in the size. So maybe we also need
>> finer-grained support to override the defaults in a few places?
>>
>> Or is there support for zipping them somehow? That appears to get a 10x
>> improvement for one of the big ones.
>>
>> Robby
>>
>>
>> On Tue, Oct 15, 2013 at 11:32 AM, Robby Findler
>> <robby at eecs.northwestern.edu <mailto:robby at eecs.**northwestern.edu<robby at eecs.northwestern.edu>>>
>> wrote:
>>
>>     Oh, right! Silly me. I've fixed 2htdp/image images so they can be
>>     converted to svgs.
>>
>>     I've also adjusted the scribble html renderer so that it treats
>>     the current-render-pict-as parameter as a suggestion on an ordering
>>     (png first or svg first) instead of insisting that all convertible
>>     things render as one or the other.
>>
>>     But now that I write this message, I'm thinking that it probably
>>     makes more sense to have a parameter whose value is a list of
>>     suggested conversions (the importance being the order) and that the
>>     parameters names should be based around the word 'convertible'
>>     instead of 'pict'.
>>
>>     Does that seem okay to you?
>>
>>     Robby
>>
>>
>>     On Tue, Oct 15, 2013 at 4:46 AM, Jens Axel Søgaard
>>     <jensaxel at soegaard.net <mailto:jensaxel at soegaard.net>**> wrote:
>>
>>         2013/10/15 Robby Findler <robby at eecs.northwestern.edu
>>         <mailto:robby at eecs.**northwestern.edu<robby at eecs.northwestern.edu>
>> >>:
>>
>>          > I gave this a try and I'm just getting "???" in the image
>>         docs. Below is my
>>          > change to the image library. Does anyone know where the ???s
>>         come from?
>>
>>         I was puzzled at first, but if I understand correctly, the HtDP
>>         images
>>         aren't picts but image-snips.
>>
>>         This implies that they don't get converted at line 585 in [1]
>>         pict-lib/texpict/private/**mrpict-extra.rkt,
>>         but that the conversion called is the one in [2]
>>         gui-lib/mrlib/image-core.rkt at line 232.
>>         I only made changes in the first one, not the second one.
>>
>>         I am unsure how to fix this - have the image snips still the
>>         pict, or
>>         have they become
>>         become bitmaps at this point?
>>
>>         [1]
>>         https://github.com/plt/racket/**blob/**
>> 5ed686d9911b9f0d1cb1d5cb58d695**0e33b9d17c/pkgs/pict-pkgs/**
>> pict-lib/texpict/private/**mrpict-extra.rkt#L585<https://github.com/plt/racket/blob/5ed686d9911b9f0d1cb1d5cb58d6950e33b9d17c/pkgs/pict-pkgs/pict-lib/texpict/private/mrpict-extra.rkt#L585>
>>
>>         [2]
>>         https://github.com/plt/racket/**blob/master/pkgs/gui-pkgs/gui-**
>> lib/mrlib/image-core.rkt#L232<https://github.com/plt/racket/blob/master/pkgs/gui-pkgs/gui-lib/mrlib/image-core.rkt#L232>
>>
>>         /Jens Axel
>>
>>
>>          > Robby
>>          >
>>          > ☕  git diff | cat
>>          > diff --git
>>          >
>>         a/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image-guide.scrbl
>>          >
>>         b/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image-guide.scrbl
>>          > index 8a625611..d66c922 100644
>>          > ---
>>         a/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image-guide.scrbl
>>          > +++
>>         b/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image-guide.scrbl
>>          > @@ -12,7 +12,9 @@
>>          >            "img-eval.rkt"
>>          >            scribble/decode
>>          >            scribble/manual
>>          > -          scribble/eval)
>>          > +          scribble/eval
>>          > +          scribble/core
>>          > +          scribble/html-properties)
>>          >
>>          >  @(define guide-eval (make-img-eval))
>>          >
>>          > @@ -35,8 +37,8 @@
>>          >  @(interaction-eval #:eval guide-eval
>>          >                     (require racket/list racket/local))
>>          >
>>          > -
>>          > - at title[#:tag "image-guide"]{Image Guide}
>>          > + at title[#:style (style "svg" (list (render-pict-as
>> 'svg-images)))
>>          > +               #:tag "image-guide"]{Image Guide}
>>          >
>>          >  This section introduces the @racketmodname[2htdp/image]
>> library
>>          >  through a series of increasingly complex image constructions
>>          > diff --git
>>         a/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image.scrbl
>>          > b/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image.scrbl
>>          > index 9c7d447..6f3cb39 100644
>>          > ---
>>         a/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image.scrbl
>>          > +++
>>         b/pkgs/htdp-pkgs/htdp-doc/**teachpack/2htdp/scribblings/**
>> image.scrbl
>>          > @@ -34,7 +34,7 @@
>>          >       (img-eval '(extra-margin 0))))
>>          >
>>          >
>>          > - at teachpack["image"]{Images}
>>          > + at teachpack[#:svg? #t "image"]{Images}
>>          >
>>          >  @(define mode/color-and-nitty-text
>>          >     (make-splice
>>          > diff --git
>>         a/pkgs/htdp-pkgs/htdp-doc/**teachpack/htdp/scribblings/**
>> shared.rkt
>>          > b/pkgs/htdp-pkgs/htdp-doc/**teachpack/htdp/scribblings/**
>> shared.rkt
>>          > index 82ade26..b2c1b40 100644
>>          > ---
>>         a/pkgs/htdp-pkgs/htdp-doc/**teachpack/htdp/scribblings/**
>> shared.rkt
>>          > +++
>>         b/pkgs/htdp-pkgs/htdp-doc/**teachpack/htdp/scribblings/**
>> shared.rkt
>>          > @@ -1,12 +1,17 @@
>>          >  #lang racket/base
>>          >
>>          > -(require scribble/manual)
>>          > +(require scribble/manual
>>          > +         scribble/core
>>          > +         scribble/html-properties)
>>          >
>>          >  (provide teachpack
>>          >           beginner-require)
>>          >
>>          > -(define (teachpack tp . name)
>>          > +(define (teachpack #:svg? [svg? #f] tp . name)
>>          >    (apply title #:tag tp
>>          > +         #:style (if svg?
>>          > +                     (style "svg" (list (render-pict-as
>>         'svg-images)))
>>          > +                     #f)
>>          >           `(, at name ": " ,(filepath (format "~a.rkt" tp))
>>          >             ,(index (format "~a teachpack" tp)))))
>>          >
>>          > ☕  [robby at yanpu]
>>          > ~/git/plt/pkgs/htdp-pkgs/htdp-**doc/teachpack/2htdp/**
>> scribblings
>>          > ☕
>>          >
>>
>>
>>
>>         --
>>         --
>>         Jens Axel Søgaard
>>
>>
>>
>>
>>
>> ____________________
>>    Racket Users list:
>>    http://lists.racket-lang.org/**users<http://lists.racket-lang.org/users>
>>
>>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/**users <http://lists.racket-lang.org/users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131015/6271dfff/attachment-0001.html>

Posted on the users mailing list.