{"record":{"id":"fe8cedf26e5c23db","repo":"huggingface/transformers","slug":"max-size-max-size-must-be-strictly-greater-tha-fe8ced","errorCode":null,"errorMessage":"max_size = {max_size} must be strictly greater than the requested size for the smaller edge size = {size}","messagePattern":"max_size = (.+?) must be strictly greater than the requested size for the smaller edge size = (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/image_utils.py","lineNumber":851,"sourceCode":"            size = tuple(size)\n\n        if isinstance(size, int) or len(size) == 1:\n            if default_to_square:\n                size = (size, size) if isinstance(size, int) else (size[0], size[0])\n            else:\n                width, height = image.size\n                # specified size only for the smallest edge\n                short, long = (width, height) if width <= height else (height, width)\n                requested_new_short = size if isinstance(size, int) else size[0]\n\n                if short == requested_new_short:\n                    return image\n\n                new_short, new_long = requested_new_short, int(requested_new_short * long / short)\n\n                if max_size is not None:\n                    if max_size <= requested_new_short:\n                        raise ValueError(\n                            f\"max_size = {max_size} must be strictly greater than the requested \"\n                            f\"size for the smaller edge size = {size}\"\n                        )\n                    if new_long > max_size:\n                        new_short, new_long = int(max_size * new_short / new_long), max_size\n\n                size = (new_short, new_long) if width <= height else (new_long, new_short)\n\n        return image.resize(size, resample=resample)\n\n    def center_crop(self, image, size):\n        \"\"\"\n        Crops `image` to the given size using a center crop. Note that if the image is too small to be cropped to the\n        size given, it will be padded (so the returned result has the size asked).\n\n        Args:\n            image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor` of shape (n_channels, height, width) or (height, width, n_channels)):\n                The image to resize.","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/image_utils.py#L833-L869","documentation":"Error \"max_size = {max_size} must be strictly greater than the requested size for the smaller edge size = {size}\" thrown in huggingface/transformers.","triggerScenarios":"Raised in resize size computation when max_size is not strictly greater than the requested shorter-edge size.","commonSituations":"size and max_size configured such that max_size <= size for the smaller edge in resize preprocessing.","solutions":["Set `max_size` strictly greater than the requested smaller-edge size.","Remove `max_size` to disable the cap."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}