Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 70 lines (51 sloc) 2.69 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
Currently when writing an animated gif you can do:

  Imager->write_multi({ type=>'gif', file=>'foo.gif',
                        gif_delays => [ (10) x @images ] },
                      @images);

and it will write out the images in @images with the given delay
between each image.

Now let's say we decide that all options are to be supplied in tags
instead of as parameters, this includes things like the jpegquality
(if possible) and tiff text tags.

The problem with this is that we're making it harder to write the
image, rather than supplying the parameters to write*() the user needs
to go through an set tags:

  $_->addtag(name=>'gif_delay', value=>10) for @images;
  Imager->write_multi({ type=>'gif', file=>'foo.gif'},
                      @images);

It's worse if the user needs to set more options:

  $_->addtag(name=>'gif_delay', value=>10) for @images;
  $_->addtag(name=>'gif_user_input', value=>1) for @images;
  Imager->write_multi({ type=>'gif', file=>'foo.gif'},
                      @images);

Now we could add a function to simplify this:

  $_->addtags(gif_delay=>10, gif_user_input=>1) for @images;
  Imager->write_multi({ type=>'gif', file=>'foo.gif'},
                      @images);

but consider how we can preserve some of the existing interface.

The option I was considering was to have the write*() methods set any
parameters that have the file type as a prefix in the write call, as
tags in the image, hence:

  Imager->write_multi({ type=>'gif', file=>'foo.gif',
                        gif_delay => [ (10) x @images ],
                        gif_user_input => [ (1) x @images ] },
                      @images);

If the value provided isn't an array reference, we could expand that to the number of images, so:

  Imager->write_multi({ type=>'gif', file=>'foo.gif',
                        gif_delay => 10,
                        gif_user_input => 1 },
                      @images);

This also applies nicely to TIFFs:

  Imager->write_multi({ type=>'tiff', file=>'foo.tiff',
                        tiff_pagename => [ map "Page $_", 1 .. @images ],
                        tiff_documentname => "My New Document" },
                      @images);

Now the names aren't going to be completely compatible between the old
interface and the new, since the gif names at least tend to be
plurals, but we do preserve the ease of use of the interface, making
it more DWIM than a "set tags then write" interface.

The main problem with this interface is we're modifying images that
we're meant to be writing to a file, which really shouldn't require
modifying the images.

We discussed some of this in IRC a while ago, but didn't come to any
decisions.
Something went wrong with that request. Please try again.