Skip to content

graphics/jpgresizetool: Add libjpeg resize tool #3143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

keever50
Copy link
Contributor

Summary

Add a libjpeg based JPEG resize tool.
Simple resizer that can resize JPEGs using
"jpgresize input.jpg output.jpg scale_denom(1,2,4,8) quality%". Tries to use little memory by scanning per line.

Impact

Allows users to quickly resize JPEG images using a simple command. Useful for in scripts to generate thumbnails or experiment with jpeg compression and size ratios.

Testing

This app is tested during the development of a project where thumbnails are generated from photos.
image
image

Add a libjpeg based JPEG resize tool.
Simple resizer that can resize JPEGs using
"jpgresize input.jpg output.jpg scale_denom(1,2,4,8) quality%".
Tries to use little memory by scanning per line.

Signed-off-by: Kevin Witteveen (MartiniMarter) <[email protected]>
#

config GRAPHICS_JPGRESIZETOOL
bool "JPGResizeTool"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add depends on libjpeg

bool "JPGResizeTool"
default n
---help---
Libjpeg JPEG resizer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use tab


/* Configuring decompressor */

struct jpeg_decompress_struct cinfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need move all variables definition to the begin of function to confirm to c89 spec.


/* All done */

printf("\rDone\n\r");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove \r from all code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, why do I need to remove \r? This makes printing behave very differently. I want the cursor to return to the beginning of the line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serial driver already do the conversion for you:
https://github.com/apache/nuttx/blob/master/drivers/serial/serial.c#L417-L433
you don't do it again in the code manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The single '\r' is intended in some parts of the code.
However, I can probably replace \n\r to \n. But keep single \r as is.

This is so we can reuse the same line to progress the loading bar instead of spawning a new loading bar on every new line. Your entire terminal would be filled up with loading bars otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@keever50
Copy link
Contributor Author

Also this tool allows a denom of 16, which is not possible. Should be removed.

@@ -0,0 +1,3 @@
ifneq ($(CONFIG_GRAPHICS_JPGRESIZETOOL),)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keever50 missing

############################################################################
# apps/graphics/jpgresizetool/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
############################################################################

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants