Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #196363

Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)

From Pieter van Oostrum <pieter-l@vanoostrum.org>
Newsgroups comp.lang.python
Subject Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
Date 2024-07-03 13:22 +0200
Message-ID <m2sewqaffl.fsf@cochabamba-1.kpn> (permalink)
References <v614q9$1m6mo$2@dont-email.me>

Show all headers | View raw


HenHanna <HenHanna@devnull.tb> writes:

> in a program like this, it makes NO difference
>                               whether i save as PNG  or  GIF ?
>
>                                  (is one smaller than the other?)
>
> black= (0,0,0)
> white= (255,255,255)  .............
>
> from PIL import Image
> from PIL import ImageDraw
>
> def newImg():
>     img = Image.new('RGB', (120, 120))
>
>     for i in range(100):
>        img.putpixel((10+i,10+i),   (red, black, white)[i%3])
>
>     img.save('test.gif')
>     return img
>

In general a 'PNG' image has better quality than 'GIF'. In a 'PNG' image all the pixels that the program generated are still present, exactly as they were generated. In a 'GIF' image, however, pixels may have been altered in order to accommodate a smaller file size. For photo-like images the difference is usually not directly visible to the eye, except when you zoom in considerably. For line-art drawings and images with sharp edges, the effect may well be visible to the naked eye.

In your particular image, there appears to be no difference: all the pixels are present as generated. But this is an exception for 'GIF' images.
-- 
Pieter van Oostrum <pieter@vanoostrum.org>
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?) HenHanna <HenHanna@devnull.tb> - 2024-07-02 08:02 -0700
  Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?) Pieter van Oostrum <pieter-l@vanoostrum.org> - 2024-07-03 13:22 +0200
    Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?) Greg Ewing <greg.ewing@canterbury.ac.nz> - 2024-07-04 03:36 +1200
      Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?) HenHanna <HenHanna@devnull.tb> - 2024-07-03 10:31 -0700
        Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?) Greg Ewing <greg.ewing@canterbury.ac.nz> - 2024-07-04 10:24 +1200
      Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?) Pieter van Oostrum <pieter-l@vanoostrum.org> - 2024-07-05 13:54 +0200

csiph-web