├── .gitignore ├── .travis.yml ├── COPYING ├── Makefile.am ├── README.md ├── autogen.sh ├── configure.ac ├── help ├── Makefile.am ├── en │ ├── Makefile.am │ ├── gimp-help.xml │ └── index.html └── images │ ├── Makefile.am │ └── wilber.png ├── misc └── gimp-screenshot.jpg ├── po ├── ChangeLog ├── POTFILES.in ├── de.po └── ka.po ├── scripts ├── check-licenses.sh ├── install-ci.sh ├── prepare-ci.sh └── run-ci.sh └── src ├── Makefile.am ├── interface.c ├── interface.h ├── main.c ├── main.h └── plugin-intl.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.gmo 3 | 4 | .deps 5 | aclocal.m4 6 | autom4te.cache/ 7 | compile 8 | config.* 9 | configure 10 | depcomp 11 | intltool-*.in 12 | install-sh 13 | Makefile 14 | Makefile.in 15 | Makefile.in.in 16 | missing 17 | po/POTFILES 18 | po/stamp-it 19 | src/heif-gimp-plugin 20 | stamp-h1 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # stats available at 2 | # https://travis-ci.org/strukturag/heif-gimp-plugin/ 3 | language: cpp 4 | compiler: 5 | - gcc 6 | - clang 7 | cache: ccache 8 | sudo: required 9 | env: 10 | - CHECK_LICENSES=1 11 | - BUILD=1 12 | - TARBALL=1 13 | 14 | matrix: 15 | exclude: 16 | - compiler: clang 17 | env: CHECK_LICENSES=1 18 | - compiler: clang 19 | env: TARBALL=1 20 | 21 | before_install: 22 | - ./scripts/install-ci.sh 23 | 24 | before_script: 25 | - ./scripts/prepare-ci.sh 26 | 27 | script: 28 | - ./scripts/run-ci.sh 29 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = po src help 4 | 5 | EXTRA_DIST = \ 6 | autogen.sh \ 7 | intltool-extract.in \ 8 | intltool-merge.in \ 9 | intltool-update.in 10 | 11 | DISTCLEANFILES = \ 12 | intltool-extract \ 13 | intltool-merge \ 14 | intltool-update 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HEIF plugin for GIMP 2 | 3 | [![Build Status](https://travis-ci.org/strukturag/heif-gimp-plugin.svg?branch=master)](https://travis-ci.org/strukturag/heif-gimp-plugin) 4 | 5 | This is a GIMP plugin for loading and saving HEIF images (High Efficiency Image File Format). 6 | 7 | HEIF is a new image file format employing HEVC (h.265) image coding for the 8 | best compression ratios currently possible. 9 | 10 | **Note: this plugin is part of GIMP v2.10.2 (or Windows v2.10.4 binaries). You only need to manually install this plugin if you are running a lower version of GIMP.** 11 | 12 | 13 | ## Screenshot 14 | 15 | ![gimp-screenshot](misc/gimp-screenshot.jpg) 16 | 17 | 18 | ## Features 19 | 20 | Loader: 21 | * HEIF files can contain several images in one file. When opening such a file, a dialog will open to let you choose the image from a list of thumbnails. 22 | * alpha channels 23 | * Exif data 24 | 25 | Saver: 26 | * adjustable quality 27 | * lossless coding 28 | 29 | ## Installation 30 | 31 | This code depends on [libheif](https://github.com/strukturag/libheif) 32 | and [libde265](https://github.com/strukturag/libde265). You should install these 33 | before compiling this plugin. 34 | 35 | This plugin uses a standard autoconf/automake build system. 36 | After downloading, run `./autogen.sh` to build the configuration scripts, 37 | then call `./configure` and `make`. 38 | Make sure that you compile and install [libde265](https://github.com/strukturag/libde265) 39 | first, then [libheif](https://github.com/strukturag/libheif), so that the configuration script will find both. 40 | Preferably, download the `frame-parallel` branch of libde265, as this uses a 41 | more recent API than the version in the `master` branch. 42 | 43 | After compilation, copy the file `src/heif-gimp-plugin` into your GIMP plugin directory 44 | (for example, `$HOME/.gimp-2.8/plug-ins`). 45 | When starting GIMP, the HEIF file-format should now show in the list of supported formats when you open a file. 46 | 47 | 48 | ## License 49 | 50 | The heif-gimp-plugin is distributed under the terms of the GNU General Public License. 51 | 52 | See COPYING for more details. 53 | 54 | Copyright (c) 2018 Struktur AG / Contact: Dirk Farin farin@struktur.de 55 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script does all the magic calls to automake/autoconf and 4 | # friends that are needed to configure a cvs checkout. You need a 5 | # couple of extra tools to run this script successfully. 6 | # 7 | # If you are compiling from a released tarball you don't need these 8 | # tools and you shouldn't use this script. Just call ./configure 9 | # directly. 10 | 11 | PROJECT="GIMP HEIF format plugin" 12 | TEST_TYPE=-f 13 | FILE=src/main.c 14 | 15 | GLIB_REQUIRED_VERSION=2.0.0 16 | INTLTOOL_REQUIRED_VERSION=0.17 17 | 18 | srcdir=`dirname $0` 19 | test -z "$srcdir" && srcdir=. 20 | ORIGDIR=`pwd` 21 | cd $srcdir 22 | 23 | check_version () 24 | { 25 | # This does not work either, because we might have numbers like 1.2.3 ... 26 | # if [ "$(echo "$1 > $2" | bc)" -eq 1 ]; then 27 | 28 | if expr $1 \>= $2 > /dev/null; then 29 | echo "yes (version $1)" 30 | else 31 | echo "Too old (found version $1)!" 32 | DIE=1 33 | fi 34 | } 35 | 36 | echo 37 | echo "I am testing that you have the required versions of autoconf," 38 | echo "automake, glib-gettextize and intltoolize..." 39 | echo 40 | 41 | DIE=0 42 | 43 | echo "checking for autoconf ... " 44 | if ! (autoconf --version) < /dev/null > /dev/null 2>&1; then 45 | echo 46 | echo " You must have autoconf installed to compile $PROJECT." 47 | echo " Download the appropriate package for your distribution," 48 | echo " or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" 49 | DIE=1; 50 | fi 51 | 52 | echo "checking for automake ... " 53 | if ! (automake --version) < /dev/null > /dev/null 2>&1; then 54 | echo 55 | echo " You must have automake 1.6 or newer installed to compile $PROJECT." 56 | echo " Download the appropriate package for your distribution," 57 | echo " or get the source tarball at ftp://ftp.gnu.org/pub/gnu/automake/" 58 | DIE=1 59 | fi 60 | 61 | echo -n "checking for glib-gettextize >= $GLIB_REQUIRED_VERSION ... " 62 | if (glib-gettextize --version) < /dev/null > /dev/null 2>&1; then 63 | VER=`glib-gettextize --version \ 64 | | grep glib-gettextize | sed "s/.* \([0-9.]*\)/\1/"` 65 | check_version $VER $GLIB_REQUIRED_VERSION 66 | else 67 | echo 68 | echo " You must have glib-gettextize installed to compile $PROJECT." 69 | echo " glib-gettextize is part of glib-2.0, so you should already" 70 | echo " have it. Make sure it is in your PATH." 71 | DIE=1 72 | fi 73 | 74 | echo -n "checking for intltool >= $INTLTOOL_REQUIRED_VERSION ... " 75 | if (intltoolize --version) < /dev/null > /dev/null 2>&1; then 76 | VER=`intltoolize --version \ 77 | | grep intltoolize | sed "s/.* \([0-9.]*\)/\1/"` 78 | check_version $VER $INTLTOOL_REQUIRED_VERSION 79 | else 80 | echo 81 | echo " You must have intltool installed to compile $PROJECT." 82 | echo " Get the latest version from" 83 | echo " ftp://ftp.gnome.org/pub/GNOME/sources/intltool/" 84 | DIE=1 85 | fi 86 | 87 | if test "$DIE" -eq 1; then 88 | echo 89 | echo "Please install/upgrade the missing tools and call me again." 90 | echo 91 | exit 1 92 | fi 93 | 94 | 95 | test $TEST_TYPE $FILE || { 96 | echo 97 | echo "You must run this script in the top-level $PROJECT directory." 98 | echo 99 | exit 1 100 | } 101 | 102 | 103 | echo 104 | echo "I am going to run ./configure with the following arguments:" 105 | echo 106 | echo " --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS $@" 107 | echo 108 | 109 | if test -z "$*"; then 110 | echo "If you wish to pass additional arguments, please specify them " 111 | echo "on the $0 command line or set the AUTOGEN_CONFIGURE_ARGS " 112 | echo "environment variable." 113 | echo 114 | fi 115 | 116 | if test -z "$ACLOCAL_FLAGS"; then 117 | 118 | acdir=`aclocal --print-ac-dir` 119 | m4list="glib-gettext.m4 intltool.m4" 120 | 121 | for file in $m4list 122 | do 123 | if [ ! -f "$acdir/$file" ]; then 124 | echo 125 | echo "WARNING: aclocal's directory is $acdir, but..." 126 | echo " no file $acdir/$file" 127 | echo " You may see fatal macro warnings below." 128 | echo " If these files are installed in /some/dir, set the ACLOCAL_FLAGS " 129 | echo " environment variable to \"-I /some/dir\", or install" 130 | echo " $acdir/$file." 131 | echo 132 | fi 133 | done 134 | fi 135 | 136 | aclocal $ACLOCAL_FLAGS 137 | RC=$? 138 | if test $RC -ne 0; then 139 | echo "aclocal gave errors. Please fix the error conditions and try again." 140 | exit 1 141 | fi 142 | 143 | # optionally feature autoheader 144 | (autoheader --version) < /dev/null > /dev/null 2>&1 && autoheader || exit 1 145 | 146 | automake --add-missing --copy || exit 1 147 | autoconf || exit 1 148 | 149 | glib-gettextize --copy --force || exit 1 150 | intltoolize --copy --force --automake || exit 1 151 | 152 | cd $ORIGDIR 153 | 154 | $srcdir/configure --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS "$@" 155 | RC=$? 156 | if test $RC -ne 0; then 157 | echo 158 | echo "Configure failed or did not finish!" 159 | exit $RC 160 | fi 161 | 162 | echo 163 | echo "Now type 'make' to compile $PROJECT." 164 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | 3 | AC_PREREQ(2.54) 4 | 5 | dnl Name your plug-in here 6 | m4_define([plugin_name], [gimp-heif-plugin]) 7 | 8 | dnl These three define the plug-in version number 9 | m4_define([plugin_major_version], [0]) 10 | m4_define([plugin_minor_version], [1]) 11 | m4_define([plugin_micro_version], [0]) 12 | 13 | m4_define([plugin_version], 14 | [plugin_major_version.plugin_minor_version.plugin_micro_version]) 15 | 16 | AC_INIT([plugin_name], [plugin_version]) 17 | 18 | AC_DEFINE(PLUGIN_NAME, PACKAGE_NAME, [Plug-In name]) 19 | AC_DEFINE(PLUGIN_VERSION, PACKAGE_VERSION, [Plug-In version]) 20 | 21 | AC_DEFINE(PLUGIN_MAJOR_VERSION, plugin_major_version, [Plug-In major version]) 22 | AC_DEFINE(PLUGIN_MINOR_VERSION, plugin_minor_version, [Plug-In minor version]) 23 | AC_DEFINE(PLUGIN_MICRO_VERSION, plugin_micro_version, [Plug-In micro version]) 24 | 25 | AC_CONFIG_SRCDIR([src/main.c]) 26 | AM_CONFIG_HEADER(config.h) 27 | 28 | AM_INIT_AUTOMAKE([foreign no-define]) 29 | 30 | AC_ISC_POSIX 31 | AC_PROG_CC 32 | AM_PROG_CC_STDC 33 | AC_HEADER_STDC 34 | 35 | AC_TYPE_UINT8_T 36 | AC_CHECK_HEADERS([libintl.h]) 37 | 38 | ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" 39 | 40 | AM_MAINTAINER_MODE 41 | 42 | 43 | dnl Use -Wall if we have gcc. 44 | changequote(,)dnl 45 | if test "x$GCC" = "xyes"; then 46 | case " $CFLAGS " in 47 | *[\ \ ]-Wall[\ \ ]*) ;; 48 | *) CFLAGS="$CFLAGS -Wall -Werror" ;; 49 | esac 50 | fi 51 | changequote([,])dnl 52 | 53 | 54 | GIMP_REQUIRED_VERSION=2.2.0 55 | 56 | PKG_CHECK_MODULES(GIMP, 57 | gimp-2.0 >= $GIMP_REQUIRED_VERSION gimpui-2.0 >= $GIMP_REQUIRED_VERSION) 58 | 59 | AC_SUBST(GIMP_CFLAGS) 60 | AC_SUBST(GIMP_LIBS) 61 | 62 | GIMP_LIBDIR=`$PKG_CONFIG --variable=gimplibdir gimp-2.0` 63 | AC_SUBST(GIMP_LIBDIR) 64 | 65 | 66 | dnl i18n stuff 67 | 68 | GETTEXT_PACKAGE=gimp20-heif-plugin 69 | AC_SUBST(GETTEXT_PACKAGE) 70 | AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", 71 | [The gettext translation domain.]) 72 | 73 | dnl Add the languages which your application supports here. 74 | ALL_LINGUAS="de" 75 | 76 | AC_PROG_INTLTOOL 77 | AM_GLIB_GNU_GETTEXT 78 | 79 | AC_CHECK_FUNCS(bind_textdomain_codeset) 80 | 81 | LOCALEDIR='${datadir}/locale' 82 | DATADIR='${datadir}/plugin_name' 83 | 84 | AC_SUBST(LOCALEDIR) 85 | AC_SUBST(DATADIR) 86 | 87 | 88 | AC_MSG_CHECKING([if GTK+ is version 2.7.0 or newer]) 89 | if $PKG_CONFIG --atleast-version=2.7.0 gtk+-2.0; then 90 | have_gtk_2_7=yes 91 | else 92 | have_gtk_2_7=no 93 | fi 94 | AC_MSG_RESULT($have_gtk_2_7) 95 | 96 | if test "x$have_gtk_2_7" != "xyes"; then 97 | CPPFLAGS="$CPPFLAGS -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED" 98 | fi 99 | 100 | 101 | AC_MSG_CHECKING([if GIMP is version 2.3.0 or newer]) 102 | if $PKG_CONFIG --atleast-version=2.3.0 gimp-2.0; then 103 | have_gimp_2_3=yes 104 | else 105 | have_gimp_2_3=no 106 | fi 107 | AC_MSG_RESULT($have_gimp_2_3) 108 | 109 | if test "x$have_gimp_2_3" != "xyes"; then 110 | CPPFLAGS="$CPPFLAGS -DGIMP_DISABLE_DEPRECATED" 111 | fi 112 | 113 | 114 | PKG_CHECK_MODULES([libheif], [libheif], [ 115 | AC_DEFINE([HAVE_LIBHEIF], [1], [Whether libheif was found.]) 116 | AC_SUBST(libheif_CFLAGS) 117 | AC_SUBST(libheif_LIBS) 118 | have_libheif="yes" 119 | ], [have_libheif="no"]) 120 | AM_CONDITIONAL([HAVE_HEIF], [test "x$have_libheif" = "xyes"]) 121 | 122 | CFLAGS="$CFLAGS -Wno-error=deprecated-declarations" 123 | 124 | AC_CONFIG_FILES([ 125 | Makefile 126 | src/Makefile 127 | po/Makefile.in 128 | help/Makefile 129 | help/en/Makefile 130 | help/images/Makefile 131 | ]) 132 | 133 | AC_OUTPUT 134 | -------------------------------------------------------------------------------- /help/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | SUBDIRS = en images 4 | -------------------------------------------------------------------------------- /help/en/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | helpdatadir = $(DATADIR)/help/en 4 | 5 | helpdata_DATA = \ 6 | gimp-help.xml \ 7 | index.html 8 | 9 | EXTRA_DIST = $(helpdata_DATA) 10 | -------------------------------------------------------------------------------- /help/en/gimp-help.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /help/en/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Help Page for gimp-plugin-template 6 | 7 | 8 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 21 | 22 | 23 | 29 | 30 |
14 | 15 |
19 | gimp-plugin-template help page 20 |
24 |

25 | Sorry but the help file for gimp-plugin-template is not yet done. 26 |

27 | /Mitch 28 |

31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /help/images/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | helpdatadir = $(DATADIR)/help/images 4 | 5 | helpdata_DATA = \ 6 | wilber.png 7 | 8 | EXTRA_DIST = $(helpdata_DATA) 9 | -------------------------------------------------------------------------------- /help/images/wilber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/strukturag/heif-gimp-plugin/510a9f517114fd602b540fb1bbe006707fede6c4/help/images/wilber.png -------------------------------------------------------------------------------- /misc/gimp-screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/strukturag/heif-gimp-plugin/510a9f517114fd602b540fb1bbe006707fede6c4/misc/gimp-screenshot.jpg -------------------------------------------------------------------------------- /po/ChangeLog: -------------------------------------------------------------------------------- 1 | 2003-11-29 Sven Neumann 2 | 3 | * POTFILES.in: added src/render.c 4 | 5 | * de.po: updated. 6 | 7 | 2003-03-05 Sven Neumann 8 | 9 | * de.po: updated. 10 | 11 | 2002-06-03 Stanislav Visnovsky 12 | 13 | * README.translators: Added explanation that this module should 14 | not be translated. 15 | 16 | 2002-04-16 Sven Neumann 17 | 18 | * Makefile.in.in: updated by intltoolize. 19 | 20 | * po2tbl.sed.in: removed. 21 | 22 | 2002-01-15 Sven Neumann 23 | 24 | * Makefile.in.in 25 | * po2tbl.sed.in: new files needed for glib-gettext. 26 | 27 | * de.po: converted to UTF-8. 28 | 29 | 2001-12-26 Pablo Saratxaga 30 | 31 | * az.po: Updated Azeri file 32 | 33 | 2001-12-21 Stanislav Visnovsky 34 | 35 | * sk.po: Added Slovak translation from Zdenko Podobny 36 | . 37 | 38 | 2001-11-09 Christian Rose 39 | 40 | * sv.po: Added Swedish translation. 41 | * update.sh: Removed this file, it should be obsoleted by 42 | intltool long ago. 43 | 44 | 2001-11-05 Abel Cheung 45 | 46 | * zh_TW.po: Updated traditional Chinese translation. 47 | 48 | 2001-10-20 Christophe Merlet 49 | 50 | * fr.po: Aded French translation from work of 51 | Xavier Delatour . 52 | 53 | 2001-08-31 Abel Cheung 54 | 55 | * zh_TW.Big5.po: Rename to ...... 56 | * zh_TW.po: This. 57 | 58 | 2001-08-07 Abel Cheung 59 | 60 | * zh_TW.Big5.po: New traditional Chinese translation. 61 | 62 | 2001-07-12 Michael Natterer 63 | 64 | * de.po: updated translation. 65 | 66 | 2000-05-24 Michael Natterer 67 | 68 | * de.po: updated translation. 69 | 70 | 2000-05-24 Michael Natterer 71 | 72 | * initial revision. 73 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of source files containing translatable strings. 2 | 3 | src/interface.c 4 | src/main.c 5 | -------------------------------------------------------------------------------- /po/de.po: -------------------------------------------------------------------------------- 1 | # This is the German locale definition for the GIMP Plug-In Template. 2 | # Copyright (C) 2000 Free Software Foundation, Inc. 3 | # Michael Natterer 4 | # 5 | msgid "" 6 | msgstr "" 7 | "Project-Id-Version: gimp-plugin-template 2.2\n" 8 | "Report-Msgid-Bugs-To: \n" 9 | "POT-Creation-Date: 2018-01-17 15:42+0100\n" 10 | "PO-Revision-Date: 2018-01-17 15:47+0100\n" 11 | "Last-Translator: Sven Neumann \n" 12 | "Language-Team: German \n" 13 | "Language: de\n" 14 | "MIME-Version: 1.0\n" 15 | "Content-Type: text/plain; charset=UTF-8\n" 16 | "Content-Transfer-Encoding: 8bit\n" 17 | "X-Generator: Poedit 1.8.7.1\n" 18 | 19 | #: ../src/interface.c:82 20 | msgid "primary" 21 | msgstr "primäres Bild" 22 | 23 | #: ../src/interface.c:208 24 | msgid "Load HEIF image content" 25 | msgstr "HEIF Bildinhalt laden" 26 | 27 | #: ../src/interface.c:219 28 | msgid "Select image" 29 | msgstr "Bild wählen" 30 | 31 | #: ../src/main.c:94 32 | msgid "Load HEIF images." 33 | msgstr "HEIF Bilder laden." 34 | 35 | #: ../src/main.c:95 36 | msgid "" 37 | "Load image stored in HEIF format (High Efficiency Image File Format). " 38 | "Typical suffices for HEIF files are .heif, .heic." 39 | msgstr "" 40 | "Bild im HEIF Format (High Efficiency Image File Format) laden. Typische " 41 | "Fileendungen für HEIF Dateien sind .heif und .heic." 42 | 43 | #: ../src/main.c:99 44 | msgid "Load HEIF image" 45 | msgstr "HEIF Bild laden" 46 | 47 | #: ../src/main.c:133 48 | msgid "Input file contains no readable images" 49 | msgstr "Eingabedatei enthält keine lesbaren Bilder" 50 | 51 | #: ../src/main.c:211 52 | msgid "image content" 53 | msgstr "HEIF Bild" 54 | 55 | #~ msgid "GIMP Plug-In Template" 56 | #~ msgstr "GIMP Plug-In Vorlage" 57 | 58 | #~ msgid "ScaleEntry Examples" 59 | #~ msgstr "ScaleEntry Beispiele" 60 | 61 | #~ msgid "Dummy 1:" 62 | #~ msgstr "Beispiel 1:" 63 | 64 | #~ msgid "Dummy scale entry 1" 65 | #~ msgstr "Scale Entry Beispiel 1" 66 | 67 | #~ msgid "Dummy 2:" 68 | #~ msgstr "Beispiel 2:" 69 | 70 | #~ msgid "Dummy scale entry 2" 71 | #~ msgstr "Scale Entry Beispiel 2" 72 | 73 | #~ msgid "Dummy 3:" 74 | #~ msgstr "Beispiel 3:" 75 | 76 | #~ msgid "Dummy scale entry 3" 77 | #~ msgstr "Scale Entry Beispiel 3" 78 | 79 | #~ msgid "A Random Seed Entry" 80 | #~ msgstr "Eingabefeld für den Anfangswert des Zufallsgenerators" 81 | 82 | #~ msgid "" 83 | #~ "A GimpCoordinates Widget\n" 84 | #~ "Initialized with the Drawable's Size" 85 | #~ msgstr "" 86 | #~ "Ein GimpCoordinates Widget\n" 87 | #~ "(Initialisiert mit der Größe des Drawables)" 88 | 89 | #~ msgid "Width:" 90 | #~ msgstr "Breite:" 91 | 92 | #~ msgid "Height:" 93 | #~ msgstr "Höhe:" 94 | 95 | #~ msgid "Image and Drawable Menu Examples" 96 | #~ msgstr "Bild und Drawable Menü Beispiele" 97 | 98 | #~ msgid "Layers:" 99 | #~ msgstr "Ebenen:" 100 | 101 | #~ msgid "RGB Images:" 102 | #~ msgstr "RGB Bilder:" 103 | 104 | #~ msgid "Plug-In Template..." 105 | #~ msgstr "GIMP Plug-In Vorlage..." 106 | 107 | #~ msgid "This plug-in is just a dummy. It has now finished doing nothing." 108 | #~ msgstr "Dieses Plug-In tut absolut nichts und damit ist es jetzt fertig." 109 | -------------------------------------------------------------------------------- /po/ka.po: -------------------------------------------------------------------------------- 1 | # Georgian translation for gimp20-heif-plugin. 2 | # Copyright (C) 2023 gimp20-heif-plugin's authors 3 | # This file is distributed under the same license as the gimp20-heif-plugin package. 4 | # Temuri Doghonadze , 2023. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: gimp-heif-plugin\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2023-02-16 08:23+0100\n" 11 | "PO-Revision-Date: 2023-02-16 08:57+0100\n" 12 | "Last-Translator: Temuri Doghonadze \n" 13 | "Language-Team: Georgian <(nothing)>\n" 14 | "Language: ka\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=UTF-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 19 | "X-Generator: Poedit 3.2.2\n" 20 | 21 | #: ../src/interface.c:82 22 | msgid "primary" 23 | msgstr "ძირითადი" 24 | 25 | #: ../src/interface.c:209 26 | msgid "Load HEIF image content" 27 | msgstr "HEIF გამოსახულების შემცველობის ჩატვირთვა" 28 | 29 | #: ../src/interface.c:220 30 | msgid "Select image" 31 | msgstr "აირჩიეთ გამოსახულება" 32 | 33 | #. int i; 34 | #: ../src/interface.c:333 35 | msgid "Save HEIF image" 36 | msgstr "HEIF გამოსახულების შენახვა" 37 | 38 | #: ../src/interface.c:344 39 | msgid "Lossless" 40 | msgstr "კარგვის გარეშე" 41 | 42 | #. gtk_container_border_width (GTK_CONTAINER (box2), 10); 43 | #: ../src/interface.c:350 44 | msgid "Quality:" 45 | msgstr "ხარისხი:" 46 | 47 | #: ../src/main.c:109 48 | msgid "Load HEIF images." 49 | msgstr "HEIF გამოსახულების ჩატვირთვა." 50 | 51 | #: ../src/main.c:110 52 | msgid "" 53 | "Load image stored in HEIF format (High Efficiency Image File Format). " 54 | "Typical suffices for HEIF files are .heif, .heic." 55 | msgstr "" 56 | "HEIF ფორმატში დამახსოვრებული გამოსახულების ჩატვირთვა (მაღალი " 57 | "ეფექტურობის გამოსახულების ფაილის ფორმატი). ტიპიურ სუფიქსებს HEIF " 58 | "ფაილებისთვის წარმოადგენენ .heif და .heic." 59 | 60 | #: ../src/main.c:114 ../src/main.c:133 61 | msgid "HEIF/HEIC" 62 | msgstr "HEIF/HEIC" 63 | 64 | #: ../src/main.c:128 65 | msgid "Save HEIF images." 66 | msgstr "HEIF გამოსახულებების შენახვა." 67 | 68 | #: ../src/main.c:129 69 | msgid "Save image in HEIF format (High Efficiency Image File Format)." 70 | msgstr "" 71 | "გამოსახულების HEIF ფორმატში შენახვა (მაღალი ეფექტურობის გამოსახულების " 72 | "ფაილის ფორმატი)." 73 | 74 | #: ../src/main.c:168 75 | msgid "Input file contains no readable images" 76 | msgstr "შეყვანილი ფაილი წაკითხვად გამოსახულებებს არ შეიცავს" 77 | 78 | #: ../src/main.c:246 79 | msgid "image content" 80 | msgstr "გამოსახულების შემცველობა" 81 | -------------------------------------------------------------------------------- /scripts/check-licenses.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | # 4 | # HEIF codec. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of libheif. 8 | # 9 | # libheif is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # libheif is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with libheif. If not, see . 21 | # 22 | 23 | echo "Checking licenses..." 24 | CHECK_RESULT=`/usr/bin/licensecheck --recursive --ignore 'emscripten|libde265|\\.git' .` 25 | 26 | # Files that are public domain or have other known-good license headers which licensecheck doesn't detect. 27 | KNOWN_GOOD_FILES=( 28 | './autogen.sh', 29 | './README.md', 30 | './src/plugin-intl.h', 31 | ) 32 | 33 | FOUND= 34 | while read -r line; do 35 | if ( echo $line | grep -q "GENERATED FILE" ); then 36 | # We don't care about generated files 37 | echo "OK: $line" 38 | continue 39 | fi 40 | 41 | if ( echo "$line" | grep -q "No copyright" ) || ( echo "$line" | grep -q "UNKNOWN" ); then 42 | FILENAME=`echo "$line" | awk '{split($0,a,":");print a[1]}'` 43 | if echo "${KNOWN_GOOD_FILES[@]}" | fgrep -q --word-regexp "${FILENAME}"; then 44 | echo "OK: $line (known-good)" 45 | else 46 | echo "ERROR: $line" >& 2 47 | FOUND=1 48 | fi 49 | continue 50 | fi 51 | 52 | echo "OK: $line" 53 | done <<< "${CHECK_RESULT}" 54 | 55 | if [ ! -z ${FOUND} ]; then 56 | echo "ERROR: Found files without licenses" >& 2 57 | exit 1 58 | fi 59 | -------------------------------------------------------------------------------- /scripts/install-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # GIMP HEIF loader / write plugin. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of gimp-libheif-plugin. 8 | # 9 | # gimp-libheif-plugin is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # gimp-libheif-plugin is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with gimp-libheif-plugin. If not, see . 21 | # 22 | 23 | INSTALL_PACKAGES= 24 | REMOVE_PACKAGES= 25 | BUILD_ROOT=$TRAVIS_BUILD_DIR 26 | 27 | if [ -z "$CHECK_LICENSES" ]; then 28 | echo "Adding PPA strukturag/libde265 ..." 29 | sudo add-apt-repository -y ppa:strukturag/libde265 30 | sudo apt-get update -qq 31 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 32 | libde265-dev \ 33 | " 34 | fi 35 | 36 | if [ ! -z "$CHECK_LICENSES" ]; then 37 | # For licensecheck 38 | sudo apt-get update 39 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 40 | devscripts \ 41 | " 42 | fi 43 | 44 | if [ -z "$CHECK_LICENSES" ]; then 45 | INSTALL_PACKAGES="$INSTALL_PACKAGES \ 46 | intltool \ 47 | libgimp2.0-dev \ 48 | " 49 | fi 50 | 51 | if [ ! -z "$INSTALL_PACKAGES" ]; then 52 | echo "Installing packages $INSTALL_PACKAGES ..." 53 | sudo apt-get install -qq $INSTALL_PACKAGES 54 | fi 55 | 56 | if [ ! -z "$REMOVE_PACKAGES" ]; then 57 | echo "Removing packages $REMOVE_PACKAGES ..." 58 | sudo apt-get remove $REMOVE_PACKAGES 59 | fi 60 | 61 | if [ -z "$CHECK_LICENSES" ]; then 62 | echo "Installing libheif ..." 63 | git clone --depth 1 -b master https://github.com/strukturag/libheif.git 64 | pushd libheif 65 | ./autogen.sh 66 | ./configure \ 67 | --prefix=$BUILD_ROOT/libheif/dist 68 | make && sudo make install 69 | popd 70 | fi 71 | -------------------------------------------------------------------------------- /scripts/prepare-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # GIMP HEIF loader / write plugin. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of gimp-libheif-plugin. 8 | # 9 | # gimp-libheif-plugin is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # gimp-libheif-plugin is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with gimp-libheif-plugin. If not, see . 21 | # 22 | 23 | INSTALL_PACKAGES= 24 | REMOVE_PACKAGES= 25 | BUILD_ROOT=$TRAVIS_BUILD_DIR 26 | 27 | if [ -z "$CHECK_LICENSES" ]; then 28 | export PKG_CONFIG_PATH=$BUILD_ROOT/libheif/dist/lib/pkgconfig/ 29 | ./autogen.sh 30 | fi 31 | -------------------------------------------------------------------------------- /scripts/run-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | # 4 | # GIMP HEIF loader / write plugin. 5 | # Copyright (c) 2018 struktur AG, Joachim Bauch 6 | # 7 | # This file is part of gimp-libheif-plugin. 8 | # 9 | # gimp-libheif-plugin is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # gimp-libheif-plugin is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with gimp-libheif-plugin. If not, see . 21 | # 22 | 23 | BUILD_ROOT=$TRAVIS_BUILD_DIR 24 | 25 | if [ ! -z "$CHECK_LICENSES" ]; then 26 | echo "Checking licenses ..." 27 | ./scripts/check-licenses.sh 28 | fi 29 | 30 | if [ ! -z "$BUILD" ]; then 31 | echo "Building libheif ..." 32 | make 33 | fi 34 | 35 | if [ ! -z "$TARBALL" ]; then 36 | VERSION=$(grep "^VERSION " Makefile | sed -r 's/^VERSION *= *([0-9]+\.[0-9]+\.[0-9]+).*/\1/g') 37 | echo "Creating tarball for version $VERSION ..." 38 | make dist 39 | 40 | export PKG_CONFIG_PATH=$BUILD_ROOT/libheif/dist/lib/pkgconfig/ 41 | 42 | echo "Building from tarball ..." 43 | tar xf gimp-heif-plugin-$VERSION.tar* 44 | pushd gimp-heif-plugin-$VERSION 45 | ./configure 46 | make 47 | popd 48 | fi 49 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | bin_PROGRAMS = heif-gimp-plugin 4 | 5 | bindir = $(GIMP_LIBDIR)/plug-ins 6 | 7 | heif_gimp_plugin_SOURCES = \ 8 | plugin-intl.h \ 9 | interface.c \ 10 | interface.h \ 11 | main.c \ 12 | main.h 13 | 14 | AM_CPPFLAGS = \ 15 | -DLOCALEDIR=\""$(LOCALEDIR)"\" \ 16 | -DDATADIR=\""$(DATADIR)"\" 17 | 18 | # LDADD = $(GIMP_LIBS) 19 | 20 | heif_gimp_plugin_CFLAGS = \ 21 | $(libheif_CFLAGS) \ 22 | -I$(top_srcdir) \ 23 | @GIMP_CFLAGS@ \ 24 | -I$(includedir) 25 | 26 | heif_gimp_plugin_LDADD = $(libheif_LIBS) $(GIMP_LIBS) 27 | -------------------------------------------------------------------------------- /src/interface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GIMP HEIF loader / write plugin. 3 | * Copyright (c) 2018 struktur AG, Dirk Farin 4 | * 5 | * This file is part of gimp-libheif-plugin. 6 | * 7 | * gimp-libheif-plugin is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * gimp-libheif-plugin is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gimp-libheif-plugin. If not, see . 19 | */ 20 | 21 | #include "config.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "main.h" 28 | #include "interface.h" 29 | 30 | #include "plugin-intl.h" 31 | 32 | 33 | #define MAX_THUMBNAIL_SIZE 320 34 | 35 | 36 | struct HeifImage 37 | { 38 | uint32_t ID; 39 | char caption[100]; // image text (filled with resolution description) 40 | struct heif_image* thumbnail; 41 | int width, height; 42 | }; 43 | 44 | 45 | gboolean load_thumbnails(struct heif_context* heif, 46 | struct HeifImage* images) 47 | { 48 | int i; 49 | 50 | int numImages = heif_context_get_number_of_top_level_images(heif); 51 | 52 | // get list of all (top level) image IDs 53 | 54 | uint32_t* IDs = (uint32_t*)alloca(numImages * sizeof(uint32_t)); 55 | heif_context_get_list_of_top_level_image_IDs(heif, IDs, numImages); 56 | 57 | 58 | // --- Load a thumbnail for each image. 59 | 60 | for (i=0; i 0) { 98 | err = heif_image_handle_get_thumbnail(handle, thumbnail_ID, &thumbnail_handle); 99 | if (err.code) { 100 | gimp_message(err.message); 101 | continue; 102 | } 103 | } 104 | else { 105 | err = heif_context_get_image_handle(heif, IDs[i], &thumbnail_handle); 106 | if (err.code) { 107 | gimp_message(err.message); 108 | continue; 109 | } 110 | } 111 | 112 | 113 | // decode the thumbnail image 114 | 115 | struct heif_image* thumbnail_img; 116 | err = heif_decode_image(thumbnail_handle, 117 | &thumbnail_img, 118 | heif_colorspace_RGB, heif_chroma_interleaved_24bit, 119 | NULL); 120 | if (err.code) { 121 | gimp_message(err.message); 122 | continue; 123 | } 124 | 125 | 126 | // if thumbnail image size exceeds the maximum, scale it down 127 | 128 | int thumbnail_width = heif_image_handle_get_width(thumbnail_handle); 129 | int thumbnail_height = heif_image_handle_get_height(thumbnail_handle); 130 | 131 | if (thumbnail_width > MAX_THUMBNAIL_SIZE || 132 | thumbnail_height > MAX_THUMBNAIL_SIZE) { 133 | 134 | // compute scaling factor to fit into a max sized box 135 | 136 | float factor_h = thumbnail_width / (float)MAX_THUMBNAIL_SIZE; 137 | float factor_v = thumbnail_height / (float)MAX_THUMBNAIL_SIZE; 138 | 139 | int new_width, new_height; 140 | 141 | if (factor_v > factor_h) { 142 | new_height = MAX_THUMBNAIL_SIZE; 143 | new_width = thumbnail_width / factor_v; 144 | } 145 | else { 146 | new_height = thumbnail_height / factor_h; 147 | new_width = MAX_THUMBNAIL_SIZE; 148 | } 149 | 150 | 151 | // scale the image 152 | 153 | struct heif_image* scaled_img = NULL; 154 | 155 | struct heif_error err = heif_image_scale_image(thumbnail_img, 156 | &scaled_img, 157 | new_width, new_height, 158 | NULL); 159 | if (err.code) { 160 | gimp_message(err.message); 161 | continue; 162 | } 163 | 164 | 165 | // release the old image and only keep the scaled down version 166 | 167 | heif_image_release(thumbnail_img); 168 | thumbnail_img = scaled_img; 169 | 170 | thumbnail_width = new_width; 171 | thumbnail_height = new_height; 172 | } 173 | 174 | heif_image_handle_release(thumbnail_handle); 175 | heif_image_handle_release(handle); 176 | 177 | 178 | // remember the HEIF thumbnail image (we need it for the GdkPixbuf) 179 | 180 | images[i].thumbnail = thumbnail_img; 181 | 182 | images[i].width = thumbnail_width; 183 | images[i].height = thumbnail_height; 184 | } 185 | 186 | return TRUE; 187 | } 188 | 189 | 190 | gboolean dialog(struct heif_context* heif, 191 | uint32_t* selected_image) 192 | { 193 | GtkWidget *dlg; 194 | GtkWidget *main_vbox; 195 | GtkWidget *frame; 196 | gboolean run = FALSE; 197 | 198 | int i; 199 | 200 | 201 | int numImages = heif_context_get_number_of_top_level_images(heif); 202 | 203 | struct HeifImage* heif_images = (struct HeifImage*)alloca(numImages * sizeof(struct HeifImage)); 204 | gboolean success = load_thumbnails(heif, heif_images); 205 | if (!success) { 206 | return FALSE; 207 | } 208 | 209 | dlg = gimp_dialog_new (_("Load HEIF image content"), PLUGIN_NAME, 210 | NULL, 0, 211 | NULL, 0, //gimp_standard_help_func, "plug-in-template", // TODO 212 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 213 | GTK_STOCK_OK, GTK_RESPONSE_OK, 214 | NULL); 215 | 216 | main_vbox = gtk_vbox_new (FALSE, 12); 217 | gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12); 218 | gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->vbox), main_vbox); 219 | 220 | frame = gimp_frame_new (_("Select image")); 221 | gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); 222 | gtk_widget_show (frame); 223 | 224 | 225 | // prepare list store with all thumbnails and caption 226 | 227 | GtkListStore* liststore; 228 | GtkTreeIter iter; 229 | 230 | liststore = gtk_list_store_new(2, G_TYPE_STRING, GDK_TYPE_PIXBUF); 231 | 232 | for (i=0; idata); 290 | gint* indices = gtk_tree_path_get_indices(path); 291 | 292 | *selected_image = heif_images[indices[0]].ID; 293 | 294 | g_list_free_full(selected_items, (GDestroyNotify) gtk_tree_path_free); 295 | } 296 | } 297 | 298 | gtk_widget_destroy (dlg); 299 | 300 | 301 | // release thumbnail images 302 | 303 | for (i=0 ; ivbox), main_vbox); 343 | 344 | lossless_button = gtk_check_button_new_with_label(_("Lossless")); 345 | gtk_box_pack_start (GTK_BOX(main_vbox), lossless_button, FALSE, FALSE, 0); 346 | 347 | 348 | hbox = gtk_hbox_new (FALSE, 10); 349 | //gtk_container_border_width (GTK_CONTAINER (box2), 10); 350 | label = gtk_label_new (_("Quality:")); 351 | quality_slider = gtk_hscale_new_with_range (0, 100, 5); 352 | gtk_scale_set_value_pos (GTK_SCALE(quality_slider), GTK_POS_RIGHT); 353 | gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, TRUE, 0); 354 | gtk_box_pack_start (GTK_BOX(hbox), quality_slider, TRUE, TRUE, 0); 355 | gtk_box_pack_start (GTK_BOX(main_vbox), hbox, TRUE, TRUE, 0); 356 | 357 | 358 | gtk_range_set_value (GTK_RANGE(quality_slider), params->quality); 359 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(lossless_button), params->lossless); 360 | gtk_widget_set_sensitive (quality_slider, !params->lossless); 361 | 362 | g_signal_connect (lossless_button, "toggled", 363 | G_CALLBACK (on_lossless_button_toggled), 364 | quality_slider); 365 | 366 | 367 | gtk_widget_show_all(dlg); 368 | 369 | run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK); 370 | 371 | if (run) { 372 | params->quality = gtk_range_get_value(GTK_RANGE(quality_slider)); 373 | params->lossless = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(lossless_button)); 374 | } 375 | 376 | gtk_widget_destroy (dlg); 377 | 378 | return run; 379 | } 380 | -------------------------------------------------------------------------------- /src/interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GIMP HEIF loader / write plugin. 3 | * Copyright (c) 2018 struktur AG, Dirk Farin 4 | * 5 | * This file is part of gimp-libheif-plugin. 6 | * 7 | * gimp-libheif-plugin is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * gimp-libheif-plugin is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gimp-libheif-plugin. If not, see . 19 | */ 20 | 21 | #ifndef __INTERFACE_H__ 22 | #define __INTERFACE_H__ 23 | 24 | 25 | #include "libheif/heif.h" 26 | 27 | 28 | /* Public functions */ 29 | 30 | gboolean dialog (struct heif_context* heif, 31 | uint32_t* selected_image); 32 | 33 | 34 | struct save_parameters 35 | { 36 | gint quality; 37 | gboolean lossless; 38 | }; 39 | 40 | gboolean save_dialog (struct save_parameters* params); 41 | 42 | #endif /* __INTERFACE_H__ */ 43 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GIMP HEIF loader / write plugin. 3 | * Copyright (c) 2018 struktur AG, Dirk Farin 4 | * 5 | * This file is part of gimp-libheif-plugin. 6 | * 7 | * gimp-libheif-plugin is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * gimp-libheif-plugin is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gimp-libheif-plugin. If not, see . 19 | */ 20 | 21 | #include "config.h" 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include "main.h" 30 | #include "interface.h" 31 | 32 | #include "plugin-intl.h" 33 | 34 | #include "libheif/heif.h" 35 | 36 | 37 | /* Constants */ 38 | 39 | #define LOAD_PROC "load_heif_file" 40 | #define SAVE_PROC "save_heif_file" 41 | 42 | /* Local function prototypes */ 43 | 44 | static void query(void); 45 | 46 | static void run(const gchar *name, 47 | gint nparams, 48 | const GimpParam *param, 49 | gint *nreturn_vals, 50 | GimpParam **return_vals); 51 | 52 | 53 | GimpPlugInInfo PLUG_IN_INFO = 54 | { 55 | NULL, /* init_proc */ 56 | NULL, /* quit_proc */ 57 | query, /* query_proc */ 58 | run, /* run_proc */ 59 | }; 60 | 61 | 62 | MAIN () 63 | 64 | 65 | static void 66 | query (void) 67 | { 68 | static const GimpParamDef load_args[] = 69 | { 70 | { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-NONINTERACTIVE (1) }" }, 71 | { GIMP_PDB_STRING, "filename", "The name of the file to load" }, 72 | { GIMP_PDB_STRING, "raw-filename", "The name entered" } 73 | }; 74 | 75 | static const GimpParamDef load_return_vals[] = 76 | { 77 | { GIMP_PDB_IMAGE, "image", "Output image" } 78 | }; 79 | 80 | 81 | static const GimpParamDef save_args[] = 82 | { 83 | { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-NONINTERACTIVE (1) }" }, 84 | { GIMP_PDB_IMAGE, "image", "Input image" }, 85 | { GIMP_PDB_DRAWABLE, "drawable", "Drawable to export" }, 86 | { GIMP_PDB_STRING, "filename", "The name of the file to export the image in" }, 87 | { GIMP_PDB_STRING, "raw-filename", "The name of the file to export the image in" }, 88 | { GIMP_PDB_INT32, "quality", "Quality factor (range: 0-100. 0 = worst, 100 = best)" }, 89 | { GIMP_PDB_INT32, "lossless", "Use lossless compression (0 = lossy, 1 = lossless)" } 90 | }; 91 | 92 | 93 | gimp_plugin_domain_register (PLUGIN_NAME, LOCALEDIR); 94 | 95 | /* 96 | gchar *help_path; 97 | gchar *help_uri; 98 | 99 | help_path = g_build_filename (DATADIR, "help", NULL); 100 | help_uri = g_filename_to_uri (help_path, NULL, NULL); 101 | g_free (help_path); 102 | 103 | gimp_plugin_help_register ("http://developer.gimp.org/plug-in-template/help", 104 | help_uri); 105 | */ 106 | 107 | if (heif_have_decoder_for_format(heif_compression_HEVC)) { 108 | gimp_install_procedure (LOAD_PROC, 109 | _("Load HEIF images."), 110 | _("Load image stored in HEIF format (High Efficiency Image File Format). Typical suffices for HEIF files are .heif, .heic."), 111 | "Dirk Farin ", 112 | "Dirk Farin ", 113 | "2018", 114 | _("HEIF/HEIC"), 115 | NULL, 116 | GIMP_PLUGIN, 117 | G_N_ELEMENTS (load_args), 118 | G_N_ELEMENTS (load_return_vals), 119 | load_args, 120 | load_return_vals); 121 | 122 | gimp_register_load_handler(LOAD_PROC, "heic,heif", ""); // TODO: 'avci' 123 | } 124 | 125 | 126 | if (heif_have_encoder_for_format(heif_compression_HEVC)) { 127 | gimp_install_procedure (SAVE_PROC, 128 | _("Save HEIF images."), 129 | _("Save image in HEIF format (High Efficiency Image File Format)."), 130 | "Dirk Farin ", 131 | "Dirk Farin ", 132 | "2018", 133 | _("HEIF/HEIC"), 134 | "RGB*", 135 | GIMP_PLUGIN, 136 | G_N_ELEMENTS (save_args), 137 | 0, // # return values 138 | save_args, 139 | NULL); // return values 140 | 141 | gimp_register_save_handler(SAVE_PROC, "heic,heif", ""); // TODO: 'avci' 142 | } 143 | } 144 | 145 | 146 | 147 | #define LOAD_HEIF_ERROR -1 148 | #define LOAD_HEIF_CANCEL -2 149 | 150 | gint32 load_heif(const gchar *filename, int interactive) 151 | { 152 | struct heif_error err; 153 | 154 | struct heif_context* ctx = heif_context_alloc(); 155 | err = heif_context_read_from_file(ctx, filename, NULL); 156 | if (err.code) { 157 | gimp_message(err.message); 158 | heif_context_free(ctx); 159 | return LOAD_HEIF_ERROR; 160 | } 161 | 162 | 163 | // analyze image content 164 | // Is there more than one image? Which image is the primary image? 165 | 166 | int num = heif_context_get_number_of_top_level_images(ctx); 167 | if (num==0) { 168 | gimp_message(_("Input file contains no readable images")); 169 | heif_context_free(ctx); 170 | return LOAD_HEIF_ERROR; 171 | } 172 | 173 | 174 | // get the primary image 175 | 176 | heif_item_id primary; 177 | 178 | err = heif_context_get_primary_image_ID(ctx, &primary); 179 | if (err.code) { 180 | gimp_message(err.message); 181 | heif_context_free(ctx); 182 | return LOAD_HEIF_ERROR; 183 | } 184 | 185 | 186 | // if primary image is no top level image or not present (invalid file), just take the first image 187 | 188 | if (!heif_context_is_top_level_image_ID(ctx, primary)) { 189 | int n = heif_context_get_list_of_top_level_image_IDs(ctx, &primary, 1); 190 | assert(n==1); 191 | } 192 | 193 | 194 | heif_item_id selected_image = primary; 195 | 196 | 197 | // if there are several images in the file and we are running interactive, 198 | // let the user choose a picture 199 | 200 | if (interactive && num > 1) { 201 | if (!dialog(ctx, &selected_image)) { 202 | heif_context_free(ctx); 203 | return LOAD_HEIF_CANCEL; 204 | } 205 | } 206 | 207 | 208 | 209 | // load the picture 210 | 211 | struct heif_image_handle* handle = 0; 212 | err = heif_context_get_image_handle(ctx, selected_image, &handle); 213 | if (err.code) { 214 | gimp_message(err.message); 215 | heif_context_free(ctx); 216 | return LOAD_HEIF_ERROR; 217 | } 218 | 219 | int has_alpha = heif_image_handle_has_alpha_channel(handle); 220 | 221 | struct heif_image* img = 0; 222 | err = heif_decode_image(handle, 223 | &img, 224 | heif_colorspace_RGB, 225 | has_alpha ? heif_chroma_interleaved_32bit : 226 | heif_chroma_interleaved_24bit, 227 | NULL); 228 | 229 | if (err.code) { 230 | gimp_message(err.message); 231 | heif_image_handle_release(handle); 232 | heif_context_free(ctx); 233 | return LOAD_HEIF_ERROR; 234 | } 235 | 236 | int width = heif_image_get_width(img, heif_channel_interleaved); 237 | int height = heif_image_get_height(img, heif_channel_interleaved); 238 | 239 | 240 | // --- create GIMP image and copy HEIF image into the GIMP image (converting it to RGB) 241 | 242 | gint32 image_ID = gimp_image_new(width, height, GIMP_RGB); 243 | gimp_image_set_filename(image_ID, filename); 244 | 245 | gint32 layer_ID = gimp_layer_new(image_ID, 246 | _("image content"), 247 | width,height, 248 | has_alpha ? GIMP_RGBA_IMAGE : GIMP_RGB_IMAGE, 249 | 100.0, 250 | GIMP_NORMAL_MODE); 251 | 252 | gboolean success = gimp_image_insert_layer(image_ID, 253 | layer_ID, 254 | 0, // gint32 parent_ID, 255 | 0); // gint position); 256 | if (!success) { 257 | heif_image_release(img); 258 | gimp_image_delete(image_ID); 259 | // TODO: do we have to delete the layer? 260 | return LOAD_HEIF_ERROR; 261 | } 262 | 263 | 264 | GimpDrawable *drawable = gimp_drawable_get(layer_ID); 265 | 266 | GimpPixelRgn rgn_out; 267 | gimp_pixel_rgn_init (&rgn_out, 268 | drawable, 269 | 0,0, 270 | width,height, 271 | TRUE, TRUE); 272 | 273 | int stride; 274 | const uint8_t* data = heif_image_get_plane_readonly(img, heif_channel_interleaved, &stride); 275 | 276 | int bpp = heif_image_get_bits_per_pixel(img, heif_channel_interleaved)/8; 277 | 278 | if (stride == width*bpp) { 279 | // we can transfer the whole image at once 280 | 281 | gimp_pixel_rgn_set_rect(&rgn_out, 282 | data, 283 | 0,0,width,height); 284 | } 285 | else { 286 | int y; 287 | for (y=0;y0) { 301 | size_t data_size = heif_image_handle_get_metadata_size(handle, metadata_id); 302 | 303 | uint8_t* data = alloca(data_size); 304 | err = heif_image_handle_get_metadata(handle, metadata_id, data); 305 | 306 | const int heif_exif_skip = 4; 307 | 308 | gimp_image_attach_new_parasite(image_ID, 309 | "exif-data", 310 | 0, 311 | data_size - heif_exif_skip, 312 | data + heif_exif_skip); 313 | } 314 | 315 | gimp_drawable_flush (drawable); 316 | gimp_drawable_merge_shadow (drawable->drawable_id, TRUE); 317 | gimp_drawable_update (drawable->drawable_id, 318 | 0,0, width,height); 319 | 320 | gimp_drawable_detach(drawable); 321 | 322 | heif_image_handle_release(handle); 323 | heif_context_free(ctx); 324 | heif_image_release(img); 325 | 326 | return image_ID; 327 | } 328 | 329 | 330 | 331 | static gboolean 332 | save_image (const gchar *filename, 333 | gint32 image_ID, 334 | gint32 drawable_ID, 335 | const struct save_parameters* params, 336 | GError **error) 337 | { 338 | // --- copy GIMP image into HEIF image 339 | 340 | gint width; 341 | gint height; 342 | 343 | width = gimp_drawable_width(drawable_ID); 344 | height = gimp_drawable_height(drawable_ID); 345 | 346 | const gboolean has_alpha = gimp_drawable_has_alpha(drawable_ID); 347 | 348 | struct heif_image* image = NULL; 349 | struct heif_error err = heif_image_create(width, height, 350 | heif_colorspace_RGB, 351 | has_alpha ? heif_chroma_interleaved_32bit : heif_chroma_interleaved_24bit, 352 | &image); 353 | 354 | heif_image_add_plane(image, heif_channel_interleaved, width, height, has_alpha ? 32 : 24); 355 | 356 | int stride; 357 | uint8_t* data = heif_image_get_plane(image, heif_channel_interleaved, &stride); 358 | 359 | GimpPixelRgn rgn_in; 360 | GimpDrawable *drawable = gimp_drawable_get(drawable_ID); 361 | 362 | gimp_pixel_rgn_init(&rgn_in, drawable, 363 | 0,0,width,height, FALSE, FALSE); 364 | 365 | int y; 366 | for (y=0;yquality); 388 | heif_encoder_set_lossless(encoder, params->lossless); 389 | //heif_encoder_set_logging_level(encoder, logging_level); 390 | 391 | struct heif_image_handle* handle; 392 | err = heif_context_encode_image(context, 393 | image, 394 | encoder, 395 | NULL, 396 | &handle); 397 | if (err.code != 0) { 398 | fprintf(stderr, "error encoding image: %s (%d)\n", err.message, err.code); 399 | heif_encoder_release(encoder); 400 | heif_context_free(context); 401 | heif_image_release(image); 402 | return FALSE; 403 | } 404 | 405 | heif_image_handle_release(handle); 406 | 407 | err = heif_context_write_to_file(context, filename); 408 | if (err.code != 0) { 409 | fprintf(stderr, "error writing image to file: %s (%d)\n", err.message, err.code); 410 | heif_encoder_release(encoder); 411 | heif_context_free(context); 412 | heif_image_release(image); 413 | return FALSE; 414 | } 415 | 416 | heif_context_free(context); 417 | heif_image_release(image); 418 | heif_encoder_release(encoder); 419 | 420 | return TRUE; 421 | } 422 | 423 | 424 | 425 | static void 426 | run (const gchar *name, 427 | gint n_params, 428 | const GimpParam *param, 429 | gint *nreturn_vals, 430 | GimpParam **return_vals) 431 | { 432 | static GimpParam values[2]; 433 | GimpPDBStatusType status = GIMP_PDB_SUCCESS; 434 | 435 | *return_vals = values; 436 | *nreturn_vals = 1; // by default only return success code (first parameter) 437 | 438 | /* Initialize i18n support */ 439 | bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); 440 | #ifdef HAVE_BIND_TEXTDOMAIN_CODESET 441 | bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); 442 | #endif 443 | textdomain (GETTEXT_PACKAGE); 444 | 445 | gimp_ui_init (PLUGIN_NAME, TRUE); 446 | 447 | GimpRunMode run_mode = param[0].data.d_int32; 448 | 449 | if (strcmp (name, LOAD_PROC) == 0) { 450 | 451 | // Make sure all the arguments are there 452 | if (n_params != 3) 453 | status = GIMP_PDB_CALLING_ERROR; 454 | 455 | const char* filename = param[1].data.d_string; 456 | int is_interactive = (run_mode == GIMP_RUN_INTERACTIVE); 457 | 458 | if (status == GIMP_PDB_SUCCESS) { 459 | gint32 gimp_image_ID = load_heif(filename, is_interactive); 460 | 461 | if (gimp_image_ID >= 0) { 462 | *nreturn_vals = 2; 463 | values[1].type = GIMP_PDB_IMAGE; 464 | values[1].data.d_image = gimp_image_ID; 465 | } 466 | else if (gimp_image_ID == LOAD_HEIF_CANCEL) { 467 | // No image was selected. 468 | status = GIMP_PDB_CANCEL; 469 | } 470 | else { 471 | status = GIMP_PDB_EXECUTION_ERROR; 472 | } 473 | } 474 | } 475 | else if (strcmp(name, SAVE_PROC) == 0) { 476 | 477 | gint32 image_ID; 478 | gint32 drawable_ID; 479 | 480 | image_ID = param[1].data.d_int32; 481 | drawable_ID = param[2].data.d_int32; 482 | 483 | struct save_parameters params; 484 | params.lossless = FALSE; 485 | params.quality = 50; 486 | 487 | 488 | GimpExportReturn export = GIMP_EXPORT_CANCEL; 489 | 490 | switch (run_mode) { 491 | case GIMP_RUN_INTERACTIVE: 492 | case GIMP_RUN_WITH_LAST_VALS: 493 | export = gimp_export_image (&image_ID, &drawable_ID, "HEIF", 494 | GIMP_EXPORT_CAN_HANDLE_RGB | 495 | // GIMP_EXPORT_CAN_HANDLE_GRAY | // TODO 496 | GIMP_EXPORT_CAN_HANDLE_ALPHA 497 | ); 498 | 499 | if (export == GIMP_EXPORT_CANCEL) { 500 | values[0].data.d_status = GIMP_PDB_CANCEL; 501 | return; 502 | } 503 | break; 504 | default: 505 | break; 506 | } 507 | 508 | 509 | switch (run_mode) { 510 | case GIMP_RUN_INTERACTIVE: 511 | gimp_get_data (SAVE_PROC, ¶ms); 512 | 513 | if (! save_dialog(¶ms)) 514 | status = GIMP_PDB_CANCEL; 515 | break; 516 | 517 | case GIMP_RUN_WITH_LAST_VALS: 518 | gimp_get_data (SAVE_PROC, ¶ms); 519 | break; 520 | 521 | case GIMP_RUN_NONINTERACTIVE: 522 | /* Make sure all the arguments are there! */ 523 | if (n_params != 7) { 524 | status = GIMP_PDB_CALLING_ERROR; 525 | } 526 | else 527 | { 528 | params.quality = (param[5].data.d_int32); 529 | params.lossless = (param[6].data.d_int32); 530 | } 531 | break; 532 | } 533 | 534 | 535 | if (status == GIMP_PDB_SUCCESS) { 536 | GError* error = NULL; 537 | if (save_image (param[3].data.d_string, image_ID, drawable_ID, ¶ms, 538 | &error)) { 539 | /* Store psvals data */ 540 | gimp_set_data (SAVE_PROC, ¶ms, sizeof (params)); 541 | } 542 | else { 543 | status = GIMP_PDB_EXECUTION_ERROR; 544 | } 545 | } 546 | } 547 | else { 548 | status = GIMP_PDB_CALLING_ERROR; 549 | } 550 | 551 | values[0].type = GIMP_PDB_STATUS; 552 | values[0].data.d_status = status; 553 | } 554 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GIMP HEIF loader / write plugin. 3 | * Copyright (c) 2018 struktur AG, Dirk Farin 4 | * 5 | * This file is part of gimp-libheif-plugin. 6 | * 7 | * gimp-libheif-plugin is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * gimp-libheif-plugin is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with gimp-libheif-plugin. If not, see . 19 | */ 20 | 21 | #ifndef __MAIN_H__ 22 | #define __MAIN_H__ 23 | 24 | 25 | typedef struct 26 | { 27 | int selected_image; 28 | } UIResult; 29 | 30 | 31 | #endif /* __MAIN_H__ */ 32 | -------------------------------------------------------------------------------- /src/plugin-intl.h: -------------------------------------------------------------------------------- 1 | /* plugin-intl.h 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a 4 | * copy of this software and associated documentation files (the "Software"), 5 | * to deal in the Software without restriction, including without limitation 6 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | * and/or sell copies of the Software, and to permit persons to whom the 8 | * Software is furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included 11 | * in all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | * 20 | * Except as contained in this notice, the name of the Author of the 21 | * Software shall not be used in advertising or otherwise to promote the 22 | * sale, use or other dealings in this Software without prior written 23 | * authorization from the Author. 24 | */ 25 | 26 | #ifndef __PLUGIN_INTL_H__ 27 | #define __PLUGIN_INTL_H__ 28 | 29 | 30 | #ifndef GETTEXT_PACKAGE 31 | #error "config.h must be included prior to plugin-intl.h" 32 | #endif 33 | 34 | #include 35 | 36 | #define _(String) gettext (String) 37 | 38 | #ifdef gettext_noop 39 | # define N_(String) gettext_noop (String) 40 | #else 41 | # define N_(String) (String) 42 | #endif 43 | 44 | 45 | #endif /* __PLUGIN_INTL_H__ */ 46 | --------------------------------------------------------------------------------