# [PATCH] getimagesize - return named keys for width, height, type and attributes

- Thread: https://externals.io/message/53788
- Original archive: https://news-web.php.net/php.internals/53788
- Started by DIXON P. on 2011-07-08T16:10:24+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #53788 — DIXON P. — 2011-07-08T16:10:24+00:00

URL: https://externals.io/message/53788#53788

Hi,

I've attached a patch for `getimagesize()` that returns named keys for
image width, height, type and attributes values. The equivalent numeric
keys 0, 1,2  and 3 are still returned but could perhaps be deprecated in
the future?

The patch also contains updated tests to reflect the change.

Regards,
Paul Dixon

---

## #53789 — Richard Quadling — 2011-07-08T16:13:26+00:00

URL: https://externals.io/message/53788#53789 · In reply to: #53788

> Hi,
>
> I've attached a patch ...

Rename as .txt to get through the mailing list s/w.



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

---

## #53791 — DIXON P. — 2011-07-08T16:21:56+00:00

URL: https://externals.io/message/53788#53791 · In reply to: #53789

Thanks Richard,

Renamed and attached.

-----Original Message-----
From: Richard Quadling [mailto:rquadling@gmail.com] 
Sent: 08 July 2011 17:13
To: DIXON P.
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] [PATCH] getimagesize - return named keys for width, height, type and attributes


> Hi,
>
> I've attached a patch ...

Rename as .txt to get through the mailing list s/w.



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

---

## #53792 — Richard Quadling — 2011-07-08T16:28:11+00:00

URL: https://externals.io/message/53788#53792 · In reply to: #53791

> Thanks Richard,
>
> Renamed and attached.
>
> -----Original Message-----
> From: Richard Quadling [mailto:rquadling@gmail.com]
> Sent: 08 July 2011 17:13
> To: DIXON P.
> Cc: internals@lists.php.net
> Subject: Re: [PHP-DEV] [PATCH] getimagesize - return named keys for width, height, type and attributes
>
> 
> > […]
>
> Rename as .txt to get through the mailing list s/w.

For consistency, should bits and mime become 4 and 5?

This would work in the same way as using named capturing in a regex,
where you get both the position index and the name in the result array
and I think various db_fetch_as_array type functions also.



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

---

## #53894 — Paul Dixon — 2011-07-11T21:33:31+00:00

URL: https://externals.io/message/53788#53894 · In reply to: #53792

> 
> > […]
> For consistency, should bits and mime become 4 and 5?
>
> This would work in the same way as using named capturing in a regex,
> where you get both the position index and the name in the result array
> and I think various db_fetch_as_array type functions also.
>
>
>
It would be trivial to add 4, 5 and 6 for mime, channels and bits
respectively, and I can do that if people think that's best. However
personally long term, I would aim to remove the position index entries
completely.

Paul

---

## #53910 — Michael Wallner — 2011-07-12T08:23:44+00:00

URL: https://externals.io/message/53788#53910 · In reply to: #53894

> personally long term, I would aim to remove the position index entries
> completely.

Which would make it unusable with list().

Mike

---

## #53913 — Alexey Shein — 2011-07-12T09:44:17+00:00

URL: https://externals.io/message/53788#53913 · In reply to: #53910

2011/7/12 Michael Wallner <mike@php.net>:
> 
> > […]
>
> Which would make it unusable with list().
>

+1 this will be huge BC break for this function. Please, don't remove
position indexes.


>
> --
> 
> 
>
>



-- 
Regards,
Shein Alexey

---

## #53923 — DIXON P. — 2011-07-13T12:54:58+00:00

URL: https://externals.io/message/53788#53923 · In reply to: #53913

I hadn’t thought of list().

I've update the patch (attached) so that each value has both an indexed and associative entry in the returned array, so that it will still work with list().

Paul

-----Original Message-----
From: Alexey Shein [mailto:confik@gmail.com] 
Sent: 12 July 2011 10:44
To: Michael Wallner
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] [PATCH] getimagesize - return named keys for width, height, type and attributes

2011/7/12 Michael Wallner <mike@php.net>:
> 
> > […]
>
> Which would make it unusable with list().
>

+1 this will be huge BC break for this function. Please, don't remove
position indexes.


>
> --
>  To unsubscribe, 
> visit: http://www.php.net/unsub.php
>
>



--
Regards,
Shein Alexey

---

## #53924 — Arvids Godjuks — 2011-07-13T14:06:39+00:00

URL: https://externals.io/message/53788#53924 · In reply to: #53923

This one is quite positive, I'm all +1 on this as a user land developer.
