private BinaryData[] getBinaries(CreateImageContentParams params) throws IOException {
    String binaryName = params.contentData.binary.getBinaryName();
    // find file type
    String type = null;
    String filenameWithoutExtension = binaryName;

    int idx = binaryName.lastIndexOf(".");
    if (idx != -1) {
      type = binaryName.substring(idx + 1).toLowerCase();
      if ("jpg".equals(type)) {
        type = "jpeg";
      }

      filenameWithoutExtension = binaryName.substring(0, idx);
    }

    BufferedImage origImage = ImageUtil.readImage(params.contentData.binary.getBinary());

    ArrayList<BinaryData> binaryList = new ArrayList<BinaryData>();

    // Do not add original as un-labeled image with name = name-heightXwitdth

    // Add fixed size images
    binaryList.addAll(
        ContentImageUtil.createStandardSizeImages(
            origImage, ContentImageUtil.getEncodeType(type), filenameWithoutExtension));

    // add source image
    BinaryData image =
        BinaryData.createBinaryDataFromStream(null, null, "source", params.contentData);
    binaryList.add(image);

    return binaryList.toArray(new BinaryData[binaryList.size()]);
  }
  private BinaryData createBinaryData(ContentBinaryDataEntity contentBinaryData) {
    boolean anonAccess =
        contentBinaryData
            .getContentVersion()
            .getContent()
            .hasAccessRightSet(
                securityService.getAnonymousUser().getUserGroup(), ContentAccessType.READ);

    BinaryData binaryData = new BinaryData();
    binaryData.key = contentBinaryData.getBinaryData().getKey();
    binaryData.contentKey = contentBinaryData.getContentVersion().getContent().getKey().toInt();
    binaryData.setSafeFileName(contentBinaryData.getBinaryData().getName());
    binaryData.timestamp = contentBinaryData.getBinaryData().getCreatedAt();
    binaryData.anonymousAccess = anonAccess;

    BlobRecord blob = this.binaryDataDao.getBlob(contentBinaryData.getBinaryData());
    binaryData.data = blob.getAsBytes();

    return binaryData;
  }