MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / Load

Method Load

vips/vips.go:259–312  ·  view source on GitHub ↗
(
	imgdata imagedata.ImageData,
	shrink float64,
	page, pages int,
)

Source from the content-addressed store, hash-verified

257}
258
259func (img *Image) Load(
260 imgdata imagedata.ImageData,
261 shrink float64,
262 page, pages int,
263) error {
264 var tmp *C.VipsImage
265
266 source := newVipsImgproxySource(imgdata.Reader())
267 defer C.unref_imgproxy_source(source)
268
269 lo := newLoadOptions(shrink, page, pages)
270
271 err := C.int(0) //nolint:wastedassign
272
273 switch imgdata.Format() {
274 case imagetype.JPEG:
275 err = C.vips_jpegload_source_go(source, &tmp, lo)
276 case imagetype.JXL:
277 err = C.vips_jxlload_source_go(source, &tmp, lo)
278 case imagetype.PNG:
279 err = C.vips_pngload_source_go(source, &tmp, lo)
280 case imagetype.WEBP:
281 err = C.vips_webpload_source_go(source, &tmp, lo)
282 case imagetype.GIF:
283 err = C.vips_gifload_source_go(source, &tmp, lo)
284 case imagetype.SVG:
285 err = C.vips_svgload_source_go(source, &tmp, lo)
286 case imagetype.HEIC, imagetype.AVIF:
287 err = C.vips_heifload_source_go(source, &tmp, lo)
288 case imagetype.TIFF:
289 err = C.vips_tiffload_source_go(source, &tmp, lo)
290 case imagetype.BMP:
291 err = C.vips_bmpload_source_go(source, &tmp, lo)
292 case imagetype.ICO:
293 err = C.vips_icoload_source_go(source, &tmp, lo)
294 default:
295 return newVipsError("Usupported image type to load")
296 }
297 if err != 0 {
298 return Error()
299 }
300
301 img.swapAndUnref(tmp)
302
303 if imgdata.Format() == imagetype.TIFF {
304 if C.vips_fix_float_tiff(img.VipsImage, &tmp) == 0 {
305 img.swapAndUnref(tmp)
306 } else {
307 slog.Warn("Can't fix TIFF", "error", Error())
308 }
309 }
310
311 return nil
312}
313
314func (img *Image) LoadThumbnail(imgdata imagedata.ImageData) error {
315 if imgdata.Format() != imagetype.HEIC && imgdata.Format() != imagetype.AVIF {

Callers 15

SupportsLoadFunction · 0.80
SupportsSaveFunction · 0.80
cachedCStringFunction · 0.80
BytesReadMethod · 0.80
ReadMethod · 0.80
CursorMethod · 0.80
WaitMethod · 0.80
WaitMethod · 0.80
ErrorMethod · 0.80
CloseMethod · 0.80
setErrMethod · 0.80
addChunkMethod · 0.80

Calls 8

swapAndUnrefMethod · 0.95
newVipsImgproxySourceFunction · 0.85
newLoadOptionsFunction · 0.85
newVipsErrorFunction · 0.85
WarnMethod · 0.80
ErrorFunction · 0.70
ReaderMethod · 0.65
FormatMethod · 0.65

Tested by 3

BytesReadMethod · 0.64
ReadMethod · 0.64
processImageAndCheckMethod · 0.64