-
Notifications
You must be signed in to change notification settings - Fork 10
componentImageStorageServer
This component provides images and is responsible for all related works like analysing meta data, cropping and rotating images.
- [NewsStream] the image server should be able to provide a user avatar using a static page e.g. including the user's global key
- [Fans] user self publication
- [other Websites] providing content for external sites (image hosting/presentation)
- [Venues] providing the possibility to host event pictures
Since the Image Gallery has been nearly completed new requirements have established. Therefore the image server component has to be redesigned.
The basic image storage server will be embedded server deployed to Maven which can work with images in multiple ways. It may include methods we do not use but that are helpful for developers using the server.
The focus in this service is the general purpose.
Basic way to create an image in the size passed.
An unused image identifier is needed. You can store meta data for the image optionally.
You can rotate the image according to its EXIF data optionally.
Returns a success flag being true if the creation was successful and false otherwise.
parameters:
- imageIdentifier [String]: unused image identifier for the new image
- image [InputStream]: input stream of the binary image, supporting all JMagick-supported formats installed (available for Ubuntu at least: GIF, JPEG, PNG, TIFF)
- metaData [String]: JSON String containing optional meta data, checked if valid JSON only
- autoRotate [boolean]: enables the optional auto rotation according to the EXIF information
Method to use only a certain frame of the image passed.
To specify this frame you need to pass cropping information.
Returns a success flag being true if the creation was successful and false otherwise.
parameters:
- imageIdentifier [String]
- image [InputStream]
- metaData [String]
- croppingInformation [ImageFrame]: cropping values will, checked if valid concerning the image
ImageFrame
- left [int]: distance to left border specifying where the image begins
- top [int]: distance to upper border specifying where the image begins
- width [int]: width of the new image frame
- height [int]: height of the new image frame
Method to create an image in the size passed using an URL.
This URL has to be passed instead of an input stream.
Returns a success flag being true if the creation was successful and false otherwise.
parameters:
- imageIdentifier [String]
- imageUrl [String]: URL to the image that will be downloaded and stored, supporting all JMagick-supported formats installed
- metaData [String]
Method to read the original image uploaded once.
Returns the original file as it has been uploaded, before rotation and cropping has been appended.
parameters:
- imageIdentifier [String]: image identifier used by an existing image
Read the basis image - compressed image including rotation and cropping.
parameters:
- imageIdentifier [String]
Read a scaled version of the basis image.
Returns an compressed image having the size specified or the basis image if the size requested was larger than the basis image.
parameters:
- imageIdentifier [String]
- width [int]: width of the new image frame
- height [int]: height of the new image frame
- scalingType [ScalingType]: specifies the way the image scaling should happen
- FIT: downscale image until it fits in the frame
- WIDTH: downscale image until its width matches the frame width
- HEIGHT: downscale image until its height matches frame height
Note: You can not update an image itself but you can update the meta data stored.
Updates the meta data stored for an image.
The JSON passed will be appended to the stored meta data, previous values will be overridden.
Returns a success flag being true if the update was successful and false otherwise.
parameters:
- imageIdentifier [String]: image identifier used by an existing image
- metaData [String]: JSON String containing the meta data that shall be appended, checked if valid JSON only
Deletes the image specified.
Returns a success flag being true if the deletion was successful and false otherwise.
parameters:
- imageIdentifier [String]: image identifier used by an existing image
The server stores images in their original version at least. If the image was cropped and/or rotated we will store the generated version and the cropping information in a database for retrievals.
Each retrieval that provides an image size that is not existing yet will lead to a new image file having this dimension, as we assume the hard disk space wasted to be less expensive than the CPU time to compute the file to this dimension another time.
To compute the new version we use the basic JPEG image (already including our filters such as cropping and rotation).
We will hash the image identifiers to achieve a balanced directory tree.
So the directory tree will look like:
- hash(image-id)[0..n]
- basis [JPEG, may be cropped and/or rotated]
- hash.jpg
- 150x150
- hash.jpg
- 300x150
- ...
- originals
- year of upload
- day of upload
- hash(user-id)[0..n]
- hash
- hash(user-id)[0..n]
- day of upload
A database will hold the meta data of an image.
-
this paper describes facebooks architecture: http://static.usenix.org/event/osdi10/tech/full_papers/Beaver.pdf but their technology is not open sourced: http://www.quora.com/Is-Facebook-going-to-open-source-Haystack
-
http://highscalability.com/flickr-architecture and http://highscalability.com/blog/2012/6/20/ask-highscalability-how-do-i-organize-millions-of-images.html
- Christian
- Sebastian