- /* Scale image */
- if (need_scale)
- {
- struct image *img2 = image_new(io->thread, io->cols, io->rows, io->flags, io->pool);
- if (unlikely(!img2))
- goto err2;
- int result = image_scale(io->thread, img2, img);
- image_destroy(io->thread, img);
- img = img2;
- need_destroy = !io->pool;
- if (unlikely(!result))
- goto err2;
- }
-
- /* Success */
- io->image = img;
- io->image_destroy = need_destroy;
- return 1;
-
- /* Free structures */
-err:
- libmagick_destroy_read_data(rd);
-err2:
- if (need_destroy)
- image_destroy(io->thread, img);
- return 0;