Class DoNothingImageOperationService
- All Implemented Interfaces:
ImageOperationService
ImageOperationService implementation that does nothing.
Since some clients may not want to perform image operations, the presence of this service avoids
introducing a hard requirement on the default implementation,
ImageMagickImageOperationService, which introduces a requirement on the ImageMagick
commandline utility.
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyEffects(ResourceWithMetadata imageResource, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Apply the effects to theimageResourceand save it to the temp file.applyEffects(File file, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Apply the effects to thefileand save it to the temp file.applyEffectsAndStoreModifiedFile(File file, String targetUrl, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Apply the effects to thefileand store the new file to thetargetUrlapplyEffectsAndStoreModifiedResource(ResourceWithMetadata imageResource, String targetUrl, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Apply the effects to theimageResourceand store the new resource to thetargetUrlbooleanisValidImageEffectTags(org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Check that theimageEffectsTagsis validoptimizeImage(org.springframework.web.multipart.MultipartFile toOptimize) Optimizes a GIF, PNG, or JPEG in an attempt to reduce its size.optimizeImageBatch(Map<String, File> imagesToOptimize) This method will batch-optimize any GIF, PNG, and JPEG image files in the input map in an attempt to reduce their sizes.voidsetNamedOperations(List<NamedOperation> namedOperations) Set theListofNamedOperation
-
Constructor Details
-
DoNothingImageOperationService
public DoNothingImageOperationService()
-
-
Method Details
-
applyEffectsAndStoreModifiedFile
public File applyEffectsAndStoreModifiedFile(File file, String targetUrl, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Description copied from interface:ImageOperationServiceApply the effects to thefileand store the new file to thetargetUrl- Specified by:
applyEffectsAndStoreModifiedFilein interfaceImageOperationService- Parameters:
file- the image file to apply effectstargetUrl- the target url to save fileimageEffectsTags- the image effects- Returns:
- the new saved file
-
applyEffectsAndStoreModifiedResource
public ResourceWithMetadata applyEffectsAndStoreModifiedResource(ResourceWithMetadata imageResource, String targetUrl, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Description copied from interface:ImageOperationServiceApply the effects to theimageResourceand store the new resource to thetargetUrl- Specified by:
applyEffectsAndStoreModifiedResourcein interfaceImageOperationService- Parameters:
imageResource- the image resource to apply effectstargetUrl- the target url to save fileimageEffectsTags- the image effects- Returns:
- the new saved resource
-
applyEffects
public InputStream applyEffects(File file, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Description copied from interface:ImageOperationServiceApply the effects to thefileand save it to the temp file. Note: The temp file will be deleted on close.StandardOpenOption.DELETE_ON_CLOSE- Specified by:
applyEffectsin interfaceImageOperationService- Parameters:
file- the image file to apply effectsimageEffectsTags- the image effects- Returns:
- the
InputStreamto the new temp file.
-
applyEffects
public InputStream applyEffects(ResourceWithMetadata imageResource, org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Description copied from interface:ImageOperationServiceApply the effects to theimageResourceand save it to the temp file. Note: The temp file will be deleted on close.StandardOpenOption.DELETE_ON_CLOSE- Specified by:
applyEffectsin interfaceImageOperationService- Parameters:
imageResource- the image resource to apply effectsimageEffectsTags- the image effects- Returns:
- the
InputStreamto the new temp file.
-
isValidImageEffectTags
public boolean isValidImageEffectTags(org.springframework.util.MultiValueMap<String, String> imageEffectsTags) Description copied from interface:ImageOperationServiceCheck that theimageEffectsTagsis valid- Specified by:
isValidImageEffectTagsin interfaceImageOperationService- Parameters:
imageEffectsTags- the image effects- Returns:
- false if
imageEffectsTagscontains the effect names which is not configured by broadleaf.image.availableEffects property orNamedOperationand true otherwise
-
optimizeImage
Description copied from interface:ImageOperationServiceOptimizes a GIF, PNG, or JPEG in an attempt to reduce its size.If
toOptimizeis a GIF, PNG, or JPEG, it will be copied to a temporary file, optimized, and its stream will be returned. When this stream is closed, the temporary file will be deleted, as documented byStandardOpenOption.DELETE_ON_CLOSE.The given file itself is not modified, as the optimization is applied to a copy.
If
toOptimizewas not a GIF, PNG, or JPEG, the returned value will just be its unmodified stream. The temp file will be deleted on close.StandardOpenOption.DELETE_ON_CLOSE- Specified by:
optimizeImagein interfaceImageOperationService- Parameters:
toOptimize- the file to be optimized- Returns:
- the
InputStreamof the optimized file, or of the unmodified file if not a GIF, PNG, or JPEG
-
optimizeImageBatch
Description copied from interface:ImageOperationServiceThis method will batch-optimize any GIF, PNG, and JPEG image files in the input map in an attempt to reduce their sizes.This operation will write over the given files themselves.
- Specified by:
optimizeImageBatchin interfaceImageOperationService- Parameters:
imagesToOptimize- a map of normalized URLs to files that should be optimized. The content type of the files will be determined purely by examining the URLs (key), and this will be used to determine whether the file is eligible for optimization.- Returns:
- a map of the given URLs to the corresponding optimized files. Only files that were successfully optimized will be present in this result. While the resulting map will be a new instance, the instances of any keys/values will be the same as those that were supplied.
-
setNamedOperations
Description copied from interface:ImageOperationServiceSet theListofNamedOperation- Specified by:
setNamedOperationsin interfaceImageOperationService- Parameters:
namedOperations- theListofNamedOperationto set
-