Class HtmlTagBasedGenerator

java.lang.Object
org.codelibs.fess.thumbnail.impl.BaseThumbnailGenerator
org.codelibs.fess.thumbnail.impl.HtmlTagBasedGenerator
All Implemented Interfaces:
ThumbnailGenerator

public class HtmlTagBasedGenerator extends BaseThumbnailGenerator
HTML tag-based thumbnail generator that creates thumbnails from image content referenced in HTML documents. This generator extracts images from HTML content and processes them to create thumbnail images based on configured dimensions and format settings.

The generator validates image MIME types, processes image data through ImageIO operations, and applies scaling and cropping to generate thumbnails that meet the specified size requirements.

  • Constructor Details

    • HtmlTagBasedGenerator

      public HtmlTagBasedGenerator()
      Default constructor for HtmlTagBasedGenerator.
  • Method Details

    • destroy

      public void destroy()
      Destroys this thumbnail generator and releases any resources. This implementation is empty as no cleanup is required.
    • createTask

      public org.codelibs.core.misc.Tuple3<String,String,String> createTask(String path, Map<String,Object> docMap)
      Creates a thumbnail generation task for the specified document.
      Specified by:
      createTask in interface ThumbnailGenerator
      Overrides:
      createTask in class BaseThumbnailGenerator
      Parameters:
      path - the file path or URL of the document
      docMap - the document metadata map containing field values
      Returns:
      a tuple containing the generator name, thumbnail ID, and path
    • generate

      public boolean generate(String thumbnailId, File outputFile)
      Generates a thumbnail image and saves it to the specified output file.

      This method processes the image content associated with the thumbnail ID, validates the image format, applies scaling and cropping transformations, and writes the resulting thumbnail to the output file.

      Parameters:
      thumbnailId - the unique identifier for the thumbnail
      outputFile - the file where the generated thumbnail will be saved
      Returns:
      true if the thumbnail was successfully generated, false otherwise
    • isImageMimeType

      protected boolean isImageMimeType(org.codelibs.fess.crawler.entity.ResponseData responseData)
      Checks if the response data contains an image MIME type that can be processed for thumbnail generation.
      Parameters:
      responseData - the response data containing MIME type information
      Returns:
      true if the MIME type represents a supported image format, false otherwise
    • saveImage

      protected HtmlTagBasedGenerator.Result saveImage(ImageInputStream input, File outputFile) throws IOException
      Processes and saves an image from the input stream to the output file as a thumbnail.

      This method reads image data, validates dimensions, applies subsampling and scaling transformations based on configuration settings, and writes the processed thumbnail to the specified output file.

      Parameters:
      input - the image input stream containing the source image data
      outputFile - the file where the processed thumbnail will be saved
      Returns:
      the result of the image processing operation
      Throws:
      IOException - if an error occurs during image reading or writing operations