Skip to content

Conversation

@tonytw1
Copy link
Member

@tonytw1 tonytw1 commented Jul 27, 2025

What does this change?

Cropping is implemented using libvips with the image processing operations happening in memory rather than forking out to shell commands.

isGraphic decision for crop type is inferred from the number of bands in the source image.
Do not know how to implement this colour depth query in libvibs.

 // val isGraphic = !colourType.matches("True[ ]?Color.*")

Seems to yield noticeably more predictable timings for large TIFF files.
Can crop these test images while running in a container with 2Gb of memory.

Time for "POST /crops to return after making a fullset of 5:3 full frame crops of various test images.

imagemagick: 
7360x4912 image/tiff 64676976: 24068ms !!!
3301x2173 image/jpeg 1324968 : 1290ms
3500x2334 image/jpeg 2492334:  2050ms
4165x3407 image/png 26741926 : 8904ms
8640x5760 image/jpeg 27134591: 5279ms
5000x3333 image/jpeg 8674990: 2521ms

vips:
7360x4912 image/tiff 64676976 : 3982ms
3301x2173 image/jpeg 1324968 : 1127ms
3500x2334 image/jpeg 2492334 : 1307ms
4165x3407 image/png 26741926 : 5036ms
8640x5760 image/jpeg 27134591 : 4001ms
5000x3333 image/jpeg 8674990 : 1619ms

How should a reviewer test this change?

How can success be measured?

Who should look at this?

Tested? Documented?

  • locally by committer
  • locally by Guardian reviewer
  • on the Guardian's TEST environment
  • relevant documentation added or amended (if needed)

@tonytw1 tonytw1 force-pushed the libvips branch 2 times, most recently from c8f8217 to c96ff82 Compare August 11, 2025 19:06
@tonytw1 tonytw1 force-pushed the libvips branch 4 times, most recently from d296629 to 25c0148 Compare September 28, 2025 10:12
@tonytw1 tonytw1 force-pushed the libvips-cropping branch 2 times, most recently from 5997767 to 7ced3c4 Compare September 28, 2025 11:22
@tonytw1 tonytw1 force-pushed the libvips-cropping branch 6 times, most recently from c916363 to dcd3779 Compare December 30, 2025 11:08
…opject with no Futures in it.

Grouping the vips images operations in 1 tight block with no eventual side effects.
TODO restore this decision.
TODO restore this decision.
…n loaded.

So that hasAlpha and colour depth can possibly come from the actual master crop image.
…can be made at a more implementation specific level.
…he number of bands in the image.

image_get_typeof palette as an indication that the image had a palette is another good signal for isGraphic.
format and bands are likely to be required to infer colour depth.
…; leaving more RAM for off heap VIPS operations.

Cropped 20% heap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants