• Re: in a program like this, it makes NO difference , whether i save as

    From Pieter van Oostrum@3:633/280.2 to All on Wed Jul 3 21:22:06 2024
    Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)

    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]

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Greg Ewing@3:633/280.2 to All on Thu Jul 4 01:36:50 2024
    Subject: Re: in a program like this, it makes NO difference , whether i save
    as PNG or GIF ? (size?)

    On 3/07/24 11:22 pm, Pieter van Oostrum wrote:
    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.

    I think you're thinking of JPEG. PNG and GIF both use lossless
    compression, however GIF only supports 8-bit colour and 1-bit
    transparency. For images with no more than 256 distinct colours, PNG and
    GIF will probably give identical results.

    --
    Greg

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From HenHanna@3:633/280.2 to All on Thu Jul 4 03:31:00 2024
    Subject: Re: in a program like this, it makes NO difference , whether i save
    as PNG or GIF ? (size?)


    On 7/3/2024 8:36 AM, Greg Ewing wrote:
    On 3/07/24 11:22 pm, Pieter van Oostrum wrote:
    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.



    I think you're thinking of JPEG. PNG and GIF both use lossless
    compression, however GIF only supports 8-bit colour and 1-bit
    transparency. For images with no more than 256 distinct colours, PNG and
    GIF will probably give identical results.


    thank you... so it seems the GIF file is smaller but
    can show fewer colors.


    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)
  • From Greg Ewing@3:633/280.2 to All on Thu Jul 4 08:24:26 2024
    Subject: Re: in a program like this, it makes NO difference , whether i save
    as PNG or GIF ? (size?)

    On 4/07/24 5:31 am, HenHanna wrote:
    thank you...˙ so it seems the GIF file is smaller but
    ˙˙˙˙˙˙˙˙˙˙˙˙˙ can show fewer˙ colors.

    I think it depends on the image. Wikiopedia suggests that GIF
    can be smaller for small images, whereas PNG tends to be smaller
    for larger 8-bit images.

    --
    Greg



    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Pieter van Oostrum@3:633/280.2 to All on Fri Jul 5 21:54:28 2024
    Subject: 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> writes:

    On 3/07/24 11:22 pm, Pieter van Oostrum wrote:
    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.

    I think you're thinking of JPEG. PNG and GIF both use lossless
    compression, however GIF only supports 8-bit colour and 1-bit
    transparency. For images with no more than 256 distinct colours, PNG and
    GIF will probably give identical results.

    Sorry, you are right. I never use GIF anymore, so indeed I read JPG instead.
    --
    Pieter van Oostrum <pieter@vanoostrum.org>
    www: http://pieter.vanoostrum.org/
    PGP key: [8DAE142BE17999C4]

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)