Merge smaller images onto large base image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
minchadw
Posts: 3
Joined: 2013-04-20T05:13:30-07:00
Authentication code: 6789

Merge smaller images onto large base image

Post by minchadw »

I don’t know if IM is the API environment to do this, I would appreciate feedback if yes or go to another type of platform.

Require a web-based application. Required to load and interactively view a large(ish) PDF/TIFF or Geo PDF of about 100MB. Users need to interactively upload, drag/drop smaller image(s) – say personal photos (1MB jpgs) onto the base image, then save as merged image file.

Does IM manage the sampling of a large file to handle display over the web, or do I create lower resolution version of the base image to display to the user for interaction? If I user lower resolution, I need to then be able to use registration coordinates to merge the smaller images onto 100MB base image. Is IM the API to work this?

thx
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Merge smaller images onto large base image

Post by anthony »

IM can do the resampling to low resoultion, and can even output the images from PHP.
See Resize http://www.imagemagick.org/Usage/resize/

It can overlap the smaller images on the larger images
See Layering Images http://**removed**/~anthony/im/layers/
Later examples even show programmed arranging of multiple sub-images

But it can not gather the 'registration coordinates' from a user (that is up to the interface)
It can use those coordinates though.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
minchadw
Posts: 3
Joined: 2013-04-20T05:13:30-07:00
Authentication code: 6789

Re: Merge smaller images onto large base image

Post by minchadw »

Yes, I see IM has great options for resizing my original image to a size for web viewing.
From your comments, can I conclude that an app has access to the location info for the overlayed images?

An example
Base image = 64000 x 48000px
Resized image viewed in web app = 640 x 480px

Use interactively uploads image1 dragged on resized base image. I'm assuming then the api will know coordinates or attachment point for image1 relative to the resized image?

Then its a matter of taking those coordinates, reverse engineer to fit on the original base image coordinate system, and then overlap/write image1 to the base?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Merge smaller images onto large base image

Post by anthony »

Yes that seems the right way to do it.

Once you have the coordinates adjusted for you internal source image, you can 'compose' the two together.

Note that both images need to be scaled similarly on the display. -resample can resize images based on the 'resolution' or DPI of the image to that of the display. Or you can resize both using a '%' scaling factor. eg '10%' That way you keep the two images in sync for display.

POINT... -resize will resize images imperfactly. That is the final size will be rounded to the nearest integer.
However resizing using -distort will resize perfecty to the scale you specify, around the point (handle) you specify. The cost is the addition of 1 or two extra (typically transparent) pixels around the edges.
http://www.imagemagick.org/Usage/resize/#distort
But it is slower as it does cylindrical area resampling.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Merge smaller images onto large base image

Post by snibgo »

minchadw wrote:Base image = 64000 x 48000px
This will need lots of memory, of course. Around 18 GB, and probably the same again.
snibgo's IM pages: im.snibgo.com
minchadw
Posts: 3
Joined: 2013-04-20T05:13:30-07:00
Authentication code: 6789

Re: Merge smaller images onto large base image

Post by minchadw »

anthony wrote:IM can do the resampling to low resoultion, and can even output the images from PHP.
See Resize http://www.imagemagick.org/Usage/resize/

It can overlap the smaller images on the larger images
See Layering Images http://**removed**/~anthony/im/layers/
Later examples even show programmed arranging of multiple sub-images

But it can not gather the 'registration coordinates' from a user (that is up to the interface)
It can use those coordinates though.
I'm interested in the multiple sub-images. Can you check your Layering Images link above, I don't have permission to read....thx
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Merge smaller images onto large base image

Post by anthony »

Applogies
http://www.imagemagick.org/Usage/layers/

The other link is a restricted test server
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply