summaryrefslogtreecommitdiff
path: root/src/imlib.c
AgeCommit message (Collapse)AuthorLines
2022-06-13Set libcurl user agentDaniel Friesel-0/+1
The default user agent is empty, which is not that friendly. Closes #660
2022-02-08global initialization for libmagicChristian Hesse-40/+54
Add a global `magic_t magic` and initialize it just once. Also `feh_is_image()` now calls itself to check compressed files, saving some duplicate code.
2022-02-08use libmagic to detect valid file formatsChristian Hesse-83/+51
Writing our own magic bytes detection is prone to errors and an everlasting catch-up-game. Let's use libmagic to get things right, this is less code and makes things more reliable. Building without libmagic is still possible. That will make the code act like specifying FEH_SKIP_MAGIC=1, effectively passing everything to imlib2.
2022-01-03Fix spellinga1346054-2/+2
2021-12-24Disable --auto-rotate in feh builds compiled wiht Imlib2 1.7.5+Daniel Friesel-1/+2
Imlib2 v1.7.5 introduces automatic (and transparent) orientation adjustment based on EXIF orientation tags. This makes feh's --auto-rotate function both superfluous and erroneous: It doesn't know about Imlib2's adjustments, so it rotates an image which is already correctly oriented, leading to incorrect orientation. I am not aware of a simple run-time check for detecting whethen running Imlib2 < 1.7.5 or ≥ 1.7.5. For now, feh disables --auto-rotate entirely when compiled on a system with Imlib2 1.7.5+ and outputs a warning when the option is used. Rationale: The Imlib2 version available at run-time should in most cases be at least as recent as the Imlib2 version used at compile-time. So, while there may be cases where feh was compiled with Imlib2 1.7.4 and exhibits erroneous auto-rotate behaviour on an Imlib2 1.7.5 system, the inverse case (a feh with disabled auto-rotate support running on Imlib2 1.7.4) should be sufficiently rare. If it does occur, it can be remedied by compiling feh from source locally. Possible caveat: Imlib2 only adjusts for EXIF orientation when loading JPEG and TIFF images. If there are additional EXIF-aware file formats supported by feh, but not Imlib2, they lose auto-rotate support. Reference: GitHub issue #642
2021-09-09feh_http_load_image: Use mkstemps to save image with correct suffixDaniel Friesel-4/+25
This allows feh to load .gif images via libcurl, as some imlib2 versions only load gif images if the suffix is correct. It's also more convenient when using --keep-http. To achieve this, feh needs to use mkstemps. mkstemps is a non-standard extension that is available on several systems. Compile feh with "mkstemps=0" to use mkstemp instead. Closes #630
2021-07-23Fix memory leak on error pathTobias Stoeckmann-1/+1
The snprintf string argument should not be duplicated. It is not needed and also not released afterwards.
2021-07-23feh_draw_exif: Fix out of bounds array access when handling long linesDaniel Friesel-4/+3
2021-07-23Fix out of boundary access with exif (#617)Tobias Stoeckmann-15/+15
* Fix out of boundary access The while-loop is not finished when pos is set to EXIF_MAX_DATA. Instead, the loop continues and therefore tries to access data outside of the array. This is triggered when compiled with exif=1 and asan: $ feh --draw-exif image.jpg * Fixed formatting No functional change but makes previous commit easier verifiable (independent of tab space setup). * Call break; instead of setting pos2 to a magic value This is in line with the following else clause * Another cosmetic adjustment Co-authored-by: Daniel Friesel <derf@finalrewind.org>
2021-06-21Fix feh_is_image for tiny filesDavid Buchanan-1/+3
2021-06-09Add JPEG XL to supported file formatsAlistair-0/+5
Note that Imlib2 does not support JXL images out of the box. However, the imlib2-jxl loader (https://github.com/alistair7/imlib2-jxl) does.
2021-02-28Merge pull request #531 from Ferada/fix-some-warningsDaniel Friesel-3/+1
Fix some warnings from `gcc`.
2021-01-09distinguish between "missing magic bytes" and "no Imlib 2 loader" errorsDaniel Friesel-23/+47
2021-01-04Fix truncated image file descriptor leakEkho-0/+1
Fixes https://github.com/derf/feh/issues/580
2021-01-03Add heic/heif to supported file formatsDaniel Friesel-0/+5
Note that Imlib2 does not support HEIC/HEIF images out of the box. However, the imlib2-heic loader (https://github.com/vi/imlib2-heic) does. Closes #579
2020-12-05fix memory leak when (re)loading HTTP files with --no-conversion-cacheDaniel Friesel-1/+1
2020-12-05fix memory leak when using exif=1 and reloading an imageDaniel Friesel-6/+15
2020-12-05Fix memory leak in feh_draw_exifDaniel Friesel-0/+1
2020-12-05free accompanying EXIF data when freeing an imageDaniel Friesel-0/+7
This fixes two memory bugs that only manifest with exif=1 and long-running slideshows. * when feh loads an image, it writes exif data to file->ed. Previously, this data was never free'd, causing a memory leak on subsequent loads of the same file. * As file->ed is never free'd, the accumulated EXIF data consumes a significant amount of memory over time. with slideshow-delay = 10 and two days of runtime, feh may exceed 1 GB of memory usage. If the slideshow is so large that feh does not encounter the same image twice in this time, this is not detected as a memory leak, as each EXIF data chunk is referenced from the filelist. See <https://github.com/derf/feh/issues/553> for details. Closes #553
2020-11-30Check magic bytes before passing a file to Imlib2's loaderDaniel Friesel-3/+100
This works around a regression in Imlib2, which makes (un)loadable file detection quite slow when handling e.g. large video files. See <https://phab.enlightenment.org/T8739> and <https://github.com/derf/feh/issues/505> for details. Closes #505
2020-05-29Fix lossless rotate for Imlib2 ≥ 1.6Daniel Friesel-2/+4
Closes #532
2020-05-29Fix some warnings from `gcc`.Olof-Joachim Frahm-3/+1
2020-04-11update copyrightDaniel Friesel-1/+1
2020-04-11ensure cache != NULL before accessing itDaniel Friesel-1/+1
Closes #521
2020-04-08fix a memory leak when loading a non-native image more than onceDaniel Friesel-0/+12
feh_file_info_load is called even if file_info is already populated, so the original file_info struct is never freed. This results in a leak of ~44 Byte for each subsequenc image load
2020-04-05Use conversion cache for imlib2 and dcraw imagesDaniel Friesel-17/+33
2020-03-30bypass HTTP cache when reloading an imageDaniel Friesel-3/+16
2020-03-30move feh_reload_image to imlib.c (next to feh_load_image)Daniel Friesel-0/+76
2020-03-30Enable HTTP cache by defaultDaniel Friesel-0/+1
2020-03-30Enable re-using downloaded http cacheAwal Garg-2/+16
2020-03-26Quit curl cleanly even if libcurl is old.c99pedant-0/+6
Building feh 3.3 on CentOS 7 x86_64 warns `curl_quit_function` in `imlib.c` is unused: ``` cc -g -O2 -Wall -Wextra -pedantic -std=c11 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DHAVE_LIBCURL -DHAVE_VERSCMP -DHAVE_LIBXINERAMA -DHAVE_LIBEXIF -DPREFIX=\"/usr/local\" -DPACKAGE=\"feh\" -DVERSION=\"3.3\" -c -o imlib.o imlib.c imlib.c:545:12: warning: ‘curl_quit_function’ defined but not used [-Wunused-function] static int curl_quit_function(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) ^ ``` The `curl_quit_function` code was added in response to pull [#435](https://github.com/derf/feh/pull/435) In issue [#485](https://github.com/derf/feh/issues/485) a fellow CentOS 7 user had an error building feh because CentOS 7 is locked into an old version of libcurl. In the fix, a version guard was wrapped around the `curl_easy_setopt` call, but the rest of the code was unchanged. Since I don't want to maintain a local build of libcurl, I looked at the curl docs and noticed there is an older callback which serves the same purpose: https://curl.haxx.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html The difference between `PROGRESS` and `XFERINFO` is the callback's argument types, with `PROGRESS` using `double` and `XFERINFO` using `curl_off_t`: https://curl.haxx.se/libcurl/c/CURLOPT_XFERINFOFUNCTION.html The callback's return value logic and use of `CURLOPT_NOPROGRESS` is the same. For context, the latest libcurl RPM I'm getting from yum updates is `libcurl-7.29.0-54.el7_7.2.x86_64`. The "stable" versions of other distros may encounter similar issues. The CentOS 7 "End of Life" date is 2024-06-30 so you should hear the end of this by then, at least from us pesky CentOS users.
2019-11-07Guard CURLOPT_XFERINFOFUNCTION usage with LIBCURL_VERSION_NUM checkDaniel Friesel-0/+2
Closes #485
2018-12-04Declare sig_exit as volatileDaniel Friesel-1/+1
sig_exit may be changed by a signal handler, so its value should always be read from RAM.
2018-11-29Handle SIGINT while doing libcurl transfersDaniel Friesel-1/+24
See also #435
2018-11-23Decrease libcurl timeout from indefinite to 30 minutesDaniel Friesel-0/+7
2018-11-04Fix segfault when editing an image without info structDaniel Friesel-4/+12
2018-11-04Disable in-place editing by defaultDaniel Friesel-1/+1
2018-11-04Merge branch 'no-inplace-edit' of https://github.com/ulteq/feh into ↵Daniel Friesel-0/+16
ulteq-no-inplace-edit
2018-10-04Add missing EXIF rotations.Olof-Joachim Frahm-1/+13
2018-08-22Add an option to disable inplace editulteq-0/+16
2018-08-05Merge --dcraw-timeout and --magick-timeout into --conversion-timeoutDaniel Friesel-5/+5
2018-08-05Merge branch 'dcraw' of https://github.com/ulteq/feh into ulteq-dcrawDaniel Friesel-8/+102
2018-05-11Update copyright noticeDaniel Friesel-1/+1
2018-05-11Use custom temporary directory for ImageMagick calls and clean it up afterwardsDaniel Friesel-1/+50
2018-03-10Only set random seed onceDaniel Friesel-3/+0
Fixes non-random behaviour when randomizing file lists several times per second. Closes #349
2018-03-03Utilize dcraw to preview RAW filesulteq-8/+102
Uses the camera-generated thumbnail to display RAW images that could otherwise not be loaded.
2018-02-14Only check image dimensions on the fly in multiwindow and slideshow modeDaniel Friesel-0/+12
This introduces a new feh_should_ignore_image function which is called at appropriate places in those modes to skip images which are loadable but undesired.
2018-01-20Fix the --magick-timeout handlingulteq-19/+6
* Prevents nasty loading loops * Prevents zombie subprocesses * Fixes the conversion timeout detection routine
2017-12-28Always check file modification time before loading images from cacheDaniel Friesel-0/+10
2017-12-28Add option to change the imlib cache sizeulteq-0/+2
This option allows you to change the default imlib2 image cache size of 4 MiB.