Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #288: Hard drive sleeping. Let it wake up on it's own...


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

SubjectAuthor
* in a program like this, it makes NO difference , whether i save as PNG or GIF ? HenHanna
`* Re: in a program like this, it makes NO difference , whether i save as PNG or GIPieter van Oostrum
 `* Re: in a program like this, it makes NO difference , whether i save as PNG or GIGreg Ewing
  +* Re: in a program like this, it makes NO difference , whether i save as PNG or GIHenHanna
  |`- Re: in a program like this, it makes NO difference , whether i save as PNG or GIGreg Ewing
  `- Re: in a program like this, it makes NO difference , whether i save as PNG or GIPieter van Oostrum

1
Subject: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
From: HenHanna
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Tue, 2 Jul 2024 15:02 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.python
Subject: in a program like this, it makes NO difference , whether i save as
PNG or GIF ? (size?)
Date: Tue, 2 Jul 2024 08:02:32 -0700
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <v614q9$1m6mo$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 02 Jul 2024 17:02:34 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="aebd87cf5dc6d0896a340783f4e437df";
logging-data="1776344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/zXj5WMHhpBQuICqg319nr2FpZ+KVfk4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7HEmywGtAW+YzLcaKtdYX2SZjbA=
Content-Language: en-US
View all headers

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

Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
From: Pieter van Oostrum
Newsgroups: comp.lang.python
Date: Wed, 3 Jul 2024 11:22 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: pieter-l@vanoostrum.org (Pieter van Oostrum)
Newsgroups: comp.lang.python
Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
Date: Wed, 03 Jul 2024 13:22:06 +0200
Lines: 30
Message-ID: <m2sewqaffl.fsf@cochabamba-1.kpn>
References: <v614q9$1m6mo$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net RGzldw8mchK6e2leA80T7wk/QB8EM9poYSvgMIrzSzahKdO26H
Cancel-Lock: sha1:tcoEXMAMN+hgNnUzzDWVweAM9UA= sha1:jl7lNwr1Kdy7/c7Bz+KmKQvce/s= sha256:4TIRuTaWZSA6GcwxIsyDgK4Khlo5AtGk5/FfA7n6cOg=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin)
View all headers

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]

Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
From: Greg Ewing
Newsgroups: comp.lang.python
Date: Wed, 3 Jul 2024 15:36 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: in a program like this, it makes NO difference , whether i save
as PNG or GIF ? (size?)
Date: Thu, 4 Jul 2024 03:36:50 +1200
Lines: 10
Message-ID: <lel9gjF7ijsU1@mid.individual.net>
References: <v614q9$1m6mo$2@dont-email.me> <m2sewqaffl.fsf@cochabamba-1.kpn>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net dHbl7tMvOtWOVCSiVRZfywt+e+BM1iJb6tad2uu6OkFvUqLTmL
Cancel-Lock: sha1:BuaMFesjPSnYWcvrTh3Z2p6wxlo= sha256:pDNG+NijdZk4R3w2qoQBUtwJWsRJhSLM09HhvlYgwDM=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <m2sewqaffl.fsf@cochabamba-1.kpn>
View all headers

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

Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
From: HenHanna
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Wed, 3 Jul 2024 17:31 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.python
Subject: Re: in a program like this, it makes NO difference , whether i save
as PNG or GIF ? (size?)
Date: Wed, 3 Jul 2024 10:31:00 -0700
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <v641sm$29ild$3@dont-email.me>
References: <v614q9$1m6mo$2@dont-email.me> <m2sewqaffl.fsf@cochabamba-1.kpn>
<lel9gjF7ijsU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 03 Jul 2024 19:31:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="68094ffab13c1ce43b0f3d9492fb83dd";
logging-data="2411181"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IUWDB3BS4+REaKPdY/T2u9/+3GiFmUug="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BG4MdT5MGgBTUTiYq42QZJ51VPI=
Content-Language: en-US
In-Reply-To: <lel9gjF7ijsU1@mid.individual.net>
View all headers

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.

Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
From: Greg Ewing
Newsgroups: comp.lang.python
Date: Wed, 3 Jul 2024 22:24 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: in a program like this, it makes NO difference , whether i save
as PNG or GIF ? (size?)
Date: Thu, 4 Jul 2024 10:24:26 +1200
Lines: 12
Message-ID: <lem1ctFb2etU1@mid.individual.net>
References: <v614q9$1m6mo$2@dont-email.me> <m2sewqaffl.fsf@cochabamba-1.kpn>
<lel9gjF7ijsU1@mid.individual.net> <v641sm$29ild$3@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net ak5JNEfKFqzjWoxcl2K6Xg3XImRJ/PC2GIfosUQoHxKA5R8LXr
Cancel-Lock: sha1:C6XmWbHKl9a43cYQfwOaEjb93H4= sha256:GHLaLgp1j4d9nozO5Fa4MDHfVbI0T7mrdks0rQFfWlc=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <v641sm$29ild$3@dont-email.me>
View all headers

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

Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
From: Pieter van Oostrum
Newsgroups: comp.lang.python
Date: Fri, 5 Jul 2024 11:54 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: pieter-l@vanoostrum.org (Pieter van Oostrum)
Newsgroups: comp.lang.python
Subject: Re: in a program like this, it makes NO difference , whether i save as PNG or GIF ? (size?)
Date: Fri, 05 Jul 2024 13:54:28 +0200
Lines: 18
Message-ID: <m24j94vytn.fsf@cochabamba-1.kpn>
References: <v614q9$1m6mo$2@dont-email.me> <m2sewqaffl.fsf@cochabamba-1.kpn>
<lel9gjF7ijsU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net /6/SsAKE5khKRVlbqBnvbAd1R7OyzOsKLdzMZf2cPLgGOyr+K2
Cancel-Lock: sha1:H2fWdQVFJawguGKElhGEfot5eE8= sha1:j5EgtpKvxICr2nGe+dyhggKPEgs= sha256:kowSB5F8lrqWqNdXjVITb/Uj18w+t1ie/Czbl1OQJXc=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin)
View all headers

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]

1

rocksolid light 0.9.8
clearnet tor