On Sun, 12 Jan 2014 07:55:57 -0800 (PST)
disintegration <
disintegr...@gmail.com> wrote:
> The library design is pretty high-level. One can resize an image like
> this:
>
> img, _ := imglib.Open("test.jpg")
> img = img.Resize(800, 0, imglib.ResampleLanczos)
> img.Save("result.jpg")
I'd say embedding file operations into the package which really has
nothing to do with files is a bad practice in a language with such
powerful concept of interfaces like Go.
You should better have
imglib.ReadFrom(io.Reader) or imglib.ReadFrom(io.ReadSeeker) --
depending on whether your library is okay with reading the image data
sequentially or does it require seeking (like it had to when reading,
say, TIFF-formatted data). This would allow the user to present to
your library anything they see fit, starting with a simple *os.File
which is returned by a call to os.Open().
Writting would better be done using something like
imglib.SaveTo(io.Writer) or imglib.SaveTo(io.WriteSeeker).
In other words, the library interface should better be as minimal as
possible. Image resizing library has really nothing to do with files
and filesystems.