[
https://issues.apache.org/jira/browse/TS-4095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15075639#comment-15075639
]
ASF GitHub Bot commented on TS-4095:
------------------------------------
Github user bgaff commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/393#discussion_r48644527
--- Diff: plugins/experimental/webp_transform/compress.cc ---
@@ -0,0 +1,198 @@
+/** @file
+
+ ATSCPPAPI plugin to do webp transform.
+
+ @section license License
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#include <sstream>
+#include <atscppapi/Logger.h>
+#include "compress.h"
+#include "Common.h"
+
+#define MAGIC_SIZE 12;
+using std::string;
+using std::vector;
+
+
+static int
+StreamWriter(const uint8_t *data, size_t data_size, const WebPPicture
*const pic)
+{
+ WebpTransform *webp_transform = static_cast<WebpTransform
*>(pic->custom_ptr);
+ webp_transform->writeImage(reinterpret_cast<const char *>(data),
data_size);
+ return data_size ? data_size : 1;
+}
+
+const string WebpTransform::_errors[] = {
+ "OK", "OUT_OF_MEMORY: Out of memory allocating objects",
"BITSTREAM_OUT_OF_MEMORY: Out of memory re-allocating byte buffer",
+ "NULL_PARAMETER: NULL parameter passed to function",
"INVALID_CONFIGURATION: configuration is invalid",
+ "BAD_DIMENSION: Bad picture dimension. Maximum width and height "
+ "allowed is 16383 pixels.",
+ "PARTITION0_OVERFLOW: Partition #0 is too big to fit 512k.\n"
+ "To reduce the size of this partition, try using less segments "
+ "with the -segments option, and eventually reduce the number of "
+ "header bits using -partition_limit. More details are available "
+ "in the manual (`man cwebp`)",
+ "PARTITION_OVERFLOW: Partition is too big to fit 16M", "BAD_WRITE:
Picture writer returned an I/O error",
+ "FILE_TOO_BIG: File would be too big to fit in 4G", "USER_ABORT:
encoding abort requested by user"};
+
+void
+WebpTransform::_webpMemoryWriterClear()
+{
+ if (_writer.mem != NULL) {
+ free(_writer.mem);
+ _writer.mem = NULL;
+ _writer.size = 0;
+ _writer.max_size = 0;
+ }
+}
+
+
+WebpTransform::InputFileFormat
+WebpTransform::_getImageType(std::stringstream &input_img)
+{
+ InputFileFormat format = UNSUPPORTED;
+ uint32_t magic1, magic2;
+ uint8_t buf[12];
+ input_img.read((char *)buf, 12);
--- End diff --
Is this the same MAGIC_SIZE as above? If so it should be used for declaring
the sizeof buf, and then you should use sizeof(buf) in the read.
> New cppapi plugin for converting image formats to wepb
> ------------------------------------------------------
>
> Key: TS-4095
> URL: https://issues.apache.org/jira/browse/TS-4095
> Project: Traffic Server
> Issue Type: New Feature
> Components: CPP API, Plugins
> Reporter: Sandeep Davu
> Assignee: Brian Geffon
> Labels: review
> Fix For: 6.2.0
>
>
> Support for png and jpeg only. Webp is a format introduced by google and can
> retain the quality of the image by reducing the image size.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)