Package com.atlassian.jira.avatar
Class AvatarTranscoderImpl
java.lang.Object
com.atlassian.jira.avatar.AvatarTranscoderImpl
- All Implemented Interfaces:
AvatarTranscoder
@ParametersAreNonnullByDefault
public class AvatarTranscoderImpl
extends Object
implements AvatarTranscoder
-
Constructor Summary
ConstructorsConstructorDescriptionAvatarTranscoderImpl(AvatarTagger avatarTagger, AvatarFileStoreProvider avatarFileStoreProvider) -
Method Summary
Modifier and TypeMethodDescriptioncom.atlassian.dc.filestore.api.FileStore.PathgetOrCreateRasterizedAvatarFile(Avatar avatar, Avatar.Size size, InputStream inputStream) Creates a PNG image file for the given avatar based on the base avatar image file which should be in SVG format.voidtranscodeAndTag(InputStream inputStream, OutputStream outputStream) Converts given SVG data to PNG format.byte[]transcodeAndTag(String imageKey, InputStream inputStream, Avatar.Size size) Converts a given SVG data to PNG format.
-
Constructor Details
-
AvatarTranscoderImpl
public AvatarTranscoderImpl(AvatarTagger avatarTagger, AvatarFileStoreProvider avatarFileStoreProvider)
-
-
Method Details
-
getOrCreateRasterizedAvatarFile
public com.atlassian.dc.filestore.api.FileStore.Path getOrCreateRasterizedAvatarFile(Avatar avatar, Avatar.Size size, InputStream inputStream) throws IOException Description copied from interface:AvatarTranscoderCreates a PNG image file for the given avatar based on the base avatar image file which should be in SVG format. The created file is also saved on disk. The subsequent requests for the same avatar and size will not trigger the conversion, previously saved file will be returned.- Specified by:
getOrCreateRasterizedAvatarFilein interfaceAvatarTranscoder- Parameters:
avatar- to be transcodedsize- of requested rasterinputStream- the data of the avatar to be transcoded- Returns:
- a handle to avatar image file in PNG format
- Throws:
IOException
-
transcodeAndTag
Description copied from interface:AvatarTranscoderConverts given SVG data to PNG format. The default avatar size will be used which isAvatar.Size.MEDIUM.- Specified by:
transcodeAndTagin interfaceAvatarTranscoder- Parameters:
inputStream- to be convertedoutputStream- to which the result should be written- Throws:
IOException
-
transcodeAndTag
public byte[] transcodeAndTag(String imageKey, InputStream inputStream, Avatar.Size size) throws IOException Description copied from interface:AvatarTranscoderConverts a given SVG data to PNG format.This method will save the converted image to disk so that if the method is invoked once again with the same
imageKeyandsizethe previous result will be returned. Therefore it is very important to chooseimageKeycarefully - it should uniquely identify the image.- Specified by:
transcodeAndTagin interfaceAvatarTranscoder- Parameters:
imageKey- name of the file thatinputStream- svg datasize- size of the output- Returns:
- byte array containing the PNG image
- Throws:
IOException
-