# language_model: Fix \`ImageSize\` storing pre-downscale dimensions \(\#54357\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/f2f9e2766b9de06f2aa79eb404c3fc4530c86a0a)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: f2f9e2766b9de06f2aa79eb404c3fc4530c86a0a

Requested commit: f2f9e2766b9de06f2aa79eb404c3fc4530c86a0a

Commit: f2f9e2766b9de06f2aa79eb404c3fc4530c86a0a

Tree: 676b268de3e039f9af3274d4312b416f929579b6

Author: Daniel Strobusch

Committer: GitHub

## Message

```
language_model: Fix `ImageSize` storing pre-downscale dimensions (#54357)

When images are resized to meet provider size constraints (Anthropic's
1568px limit or the 5MB encoded-PNG cap), the stored ImageSize was still
recording the original width/height rather than the final post-downscale
dimensions. This caused incorrect token estimation via estimate_tokens()
since it uses width * height / 750.

Use processed_image.dimensions() after all downscale passes so that
ImageSize reflects the actual image sent to the provider.

Release Notes:

- Fixed an issue where token estimation would be incorrect in case where
the thread contained downscaled images.
```

## Parents

- [edfd8c87e6214a1387b444cd82a03281e96391ac](https://git.cafe/gitcafe/zed/commit/edfd8c87e6214a1387b444cd82a03281e96391ac?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/f2f9e2766b9de06f2aa79eb404c3fc4530c86a0a?format=markdown)
