initial import
This commit is contained in:
171
maim/fix-build-without-libwebp.patch
Normal file
171
maim/fix-build-without-libwebp.patch
Normal file
@@ -0,0 +1,171 @@
|
||||
--- a/CMakeLists.txt 2024-04-10 02:30:19.000000000 +0200
|
||||
+++ b/CMakeLists.txt 2024-11-09 02:42:08.105959204 +0100
|
||||
@@ -27,7 +27,6 @@
|
||||
set( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/modules" )
|
||||
find_package( PNG REQUIRED )
|
||||
find_package( JPEG REQUIRED )
|
||||
-find_package( WebP REQUIRED )
|
||||
find_package( XRandr REQUIRED )
|
||||
find_package( XRender REQUIRED )
|
||||
find_package( XFixes REQUIRED )
|
||||
@@ -51,8 +50,7 @@
|
||||
${JPEG_INCLUDE_DIR}
|
||||
${XRANDR_INCLUDE_DIR}
|
||||
${XRENDER_INCLUDE_DIR}
|
||||
- ${PNG_INCLUDE_DIRS}
|
||||
- ${WEBP_INCLUDE_DIR} )
|
||||
+ ${PNG_INCLUDE_DIRS} )
|
||||
|
||||
# Libraries
|
||||
target_link_libraries( ${BIN_TARGET}
|
||||
@@ -64,8 +62,7 @@
|
||||
${XRANDR_LIBRARY}
|
||||
${JPEG_LIBRARIES}
|
||||
${XRENDER_LIBRARY}
|
||||
- ${SLOP_LIBRARIES}
|
||||
- ${WEBP_LIBRARY} )
|
||||
+ ${SLOP_LIBRARIES} )
|
||||
|
||||
if( ${CMAKE_VERSION} VERSION_LESS 3.7 )
|
||||
message( WARNING "CMake version is below 3.7, CMake version >= 3.7 is required for unicode support." )
|
||||
--- a/src/image.cpp 2024-04-10 02:30:19.000000000 +0200
|
||||
+++ b/src/image.cpp 2024-11-09 02:46:22.827983861 +0100
|
||||
@@ -271,32 +271,6 @@
|
||||
delete[] imageData;
|
||||
}
|
||||
|
||||
-void ARGBImage::writeWEBP( std::ostream& streamout, int quality ) {
|
||||
- // assume 4 channels
|
||||
- if (channels != 4) {
|
||||
- throw new std::runtime_error("WebP tried to save image with more than 4 channels");
|
||||
- }
|
||||
-
|
||||
- size_t size;
|
||||
- uint8_t* out;
|
||||
- if (quality == 10) {
|
||||
- // encode lossless at highest quality
|
||||
- size = WebPEncodeLosslessRGBA(data, width, height, width * 4, &out);
|
||||
- }
|
||||
- else {
|
||||
- // otherwise, encode lossy
|
||||
- size = WebPEncodeRGBA(data, width, height, width * 4, quality * 10.0f, &out);
|
||||
- }
|
||||
-
|
||||
- if (size == 0) {
|
||||
- throw new std::runtime_error("Failed to encode webp image");
|
||||
- }
|
||||
- else {
|
||||
- streamout.write((const char*)out, size);
|
||||
- WebPFree(out);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
bool ARGBImage::intersect( XRRCrtcInfo* a, glm::vec4 b ) {
|
||||
if (a->x < b.x + b.z &&
|
||||
a->x + a->width > b.x &&
|
||||
--- a/src/image.hpp 2024-04-10 02:30:19.000000000 +0200
|
||||
+++ b/src/image.hpp 2024-11-09 02:46:50.178009792 +0100
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <iostream>
|
||||
#include <png.h>
|
||||
#include <jpeglib.h>
|
||||
-#include <webp/encode.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdexcept>
|
||||
@@ -92,7 +91,6 @@
|
||||
void writePNG( std::ostream& streamout, int quality );
|
||||
void writeJPEG( std::ostream& streamout, int quality );
|
||||
void writeBMP( std::ostream& streamout );
|
||||
- void writeWEBP( std::ostream& streamout, int quality );
|
||||
};
|
||||
|
||||
#endif
|
||||
--- a/src/main.cpp 2024-04-10 02:30:19.000000000 +0200
|
||||
+++ b/src/main.cpp 2024-11-09 02:50:50.208237301 +0100
|
||||
@@ -185,7 +185,7 @@
|
||||
foo->formatGiven = options.count("format") > 0;
|
||||
if ( foo->formatGiven ) {
|
||||
foo->format = options["format"].as<std::string>();
|
||||
- if ( foo->format != "png" && foo->format != "jpg" && foo->format != "jpeg" && foo->format != "bmp" && foo->format != "webp" ) {
|
||||
+ if ( foo->format != "png" && foo->format != "jpg" && foo->format != "jpeg" && foo->format != "bmp" ) {
|
||||
throw new std::invalid_argument("Unknown format type: `" + foo->format + "`, only `png`, `jpg`, or `bmp` is allowed." );
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@
|
||||
|
||||
DESCRIPTION
|
||||
maim (make image) is an utility that takes a screenshot of your desktop,
|
||||
- and encodes a png, jpg, bmp or webp image of it. By default it outputs
|
||||
+ and encodes a png, jpg or bmp image of it. By default it outputs
|
||||
the encoded image data directly to standard output.
|
||||
|
||||
OPTIONS
|
||||
@@ -289,7 +289,7 @@
|
||||
Sets the desired output format, by default maim will attempt to
|
||||
determine the desired output format automatically from the output
|
||||
file. If that fails it defaults to a lossless png format. Cur‐
|
||||
- rently supports `png`, `jpg`, `bmp` and `webp`.
|
||||
+ rently supports `png`, `jpg` and `bmp`.
|
||||
|
||||
-i, --window=INT
|
||||
Sets the desired window to capture, defaults to the root window.
|
||||
@@ -311,10 +311,9 @@
|
||||
|
||||
-m, --quality
|
||||
An integer from 1 to 10 that determines the compression quality.
|
||||
- For lossy formats (jpg and webp), lower settings will produce
|
||||
+ For lossy formats (e.g. jpg), lower settings will produce
|
||||
smaller files with lower quality, while higher settings will inc-
|
||||
- rease quality at the cost of higher file size. A quality of 10 is
|
||||
- lossless for webp.
|
||||
+ rease quality at the cost of higher file size.
|
||||
For png, lower settings will compress faster and produce larger
|
||||
files, while higher settings will compress slower, but produce
|
||||
smaller files. No effect on bmp images.
|
||||
@@ -411,14 +410,14 @@
|
||||
("h,help", "Print help and exit.")
|
||||
("v,version", "Print version and exit.")
|
||||
("x,xdisplay", "Sets the xdisplay to use", cxxopts::value<std::string>())
|
||||
- ("f,format", "Sets the desired output format, by default maim will attempt to determine the desired output format automatically from the output file. If that fails it defaults to a lossless png format. Supports `png`, `jpg`, `bmp` and `webp`.", cxxopts::value<std::string>())
|
||||
+ ("f,format", "Sets the desired output format, by default maim will attempt to determine the desired output format automatically from the output file. If that fails it defaults to a lossless png format. Supports `png`, `jpg` and `bmp`.", cxxopts::value<std::string>())
|
||||
("i,window", "Sets the desired window to capture, defaults to the root window. Allows for an integer, hex, or `root` for input.", cxxopts::value<std::string>())
|
||||
("g,geometry", "Sets the region to capture, uses local coordinates from the given window. So -g10x30-5+0 would represent the rectangle wxh+x+y where w=10, h=30, x=-5, and y=0. x and y are the upper left location of this rectangle.", cxxopts::value<std::string>())
|
||||
("w,parent", "By default, maim assumes the --geometry values are in respect to the provided --window (or root if not provided). This parameter overrides this behavior by making the geometry be in respect to whatever window you provide to --parent. Allows for an integer, hex, or `root` for input.", cxxopts::value<std::string>())
|
||||
("B,capturebackground", "By default, when capturing a window, maim will ignore anything beneath the specified window. This parameter overrides this and also captures elements underneath the window.")
|
||||
("d,delay", "Sets the time in seconds to wait before taking a screenshot. Prints a simple message to show how many seconds are left before a screenshot is taken. See --quiet for muting this message.", cxxopts::value<float>()->implicit_value("5"))
|
||||
("u,hidecursor", "By default maim super-imposes the cursor onto the image, you can disable that behavior with this flag.")
|
||||
- ("m,quality", "An integer from 1 to 10 that determines the compression quality. For lossy formats (jpg and webp), lower settings will produce smaller files with lower quality, while higher settings will increase quality at the cost of higher file size. A quality of 10 is lossless for webp. For png, lower settings will compress faster and produce larger files, while higher settings will compress slower, but produce smaller files. No effect on bmp images.", cxxopts::value<int>())
|
||||
+ ("m,quality", "An integer from 1 to 10 that determines the compression quality. For lossy formats (e.g. jpg), lower settings will produce smaller files with lower quality, while higher settings will increase quality at the cost of higher file size. For png, lower settings will compress faster and produce larger files, while higher settings will compress slower, but produce smaller files. No effect on bmp images.", cxxopts::value<int>())
|
||||
("s,select", "Enables an interactive selection mode where you may select the desired region or window before a screenshot is captured. Uses the settings below to determine the visuals and settings of slop.")
|
||||
("b,bordersize", "Sets the selection rectangle's thickness.", cxxopts::value<float>())
|
||||
("p,padding", "Sets the padding size for the selection, this can be negative.", cxxopts::value<float>())
|
||||
@@ -476,8 +475,8 @@
|
||||
|
||||
if ( !maimOptions->formatGiven && maimOptions->savepathGiven && maimOptions->savepath.find_last_of(".") != std::string::npos ) {
|
||||
maimOptions->format = maimOptions->savepath.substr(maimOptions->savepath.find_last_of(".")+1);
|
||||
- if ( maimOptions->format != "png" && maimOptions->format != "jpg" && maimOptions->format != "jpeg" && maimOptions->format != "bmp" && maimOptions->format != "webp") {
|
||||
- throw new std::invalid_argument("Unknown format type: `" + maimOptions->format + "`, only `png`, `jpg`, `bmp` or `webp` is allowed." );
|
||||
+ if ( maimOptions->format != "png" && maimOptions->format != "jpg" && maimOptions->format != "jpeg" && maimOptions->format != "bmp") {
|
||||
+ throw new std::invalid_argument("Unknown format type: `" + maimOptions->format + "`, only `png`, `jpg` or `bmp` is allowed." );
|
||||
}
|
||||
}
|
||||
if ( !maimOptions->windowGiven ) {
|
||||
@@ -562,7 +561,7 @@
|
||||
XImage* image = x11->getImage( selection.id, px, py, selection.w, selection.h, imageloc);
|
||||
|
||||
int num_channels;
|
||||
- if ( maimOptions->format == "png" || maimOptions->format == "webp" ) {
|
||||
+ if ( maimOptions->format == "png" ) {
|
||||
// Convert it to an ARGB format, clipping it to the selection
|
||||
num_channels = 4;
|
||||
} else {
|
||||
@@ -587,8 +586,6 @@
|
||||
convert.writeJPEG(*out, maimOptions->quality );
|
||||
} else if ( maimOptions->format == "bmp" ) {
|
||||
convert.writeBMP(*out);
|
||||
- } else if ( maimOptions->format == "webp" ) {
|
||||
- convert.writeWEBP(*out, maimOptions->quality);
|
||||
}
|
||||
|
||||
XDestroyImage( image );
|
||||
Reference in New Issue
Block a user