77*
88* This file part of: SCAMP
99*
10- * Copyright: (C) 1998 -2021 IAP/CNRS/SorbonneU
10+ * Copyright: (C) 2002 -2021 IAP/CNRS/SorbonneU
1111* (C) 2021-2023 CFHT/CNRS
1212* (C) 2023-2025 CEA/AIM/UParisSaclay
1313*
2424* You should have received a copy of the GNU General Public License
2525* along with SCAMP. If not, see <http://www.gnu.org/licenses/>.
2626*
27- * Last modified: 27/03 /2025
27+ * Last modified: 09/04 /2025
2828*
2929*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
3030
6565#include "fitswcs.h"
6666
6767int findkeys (char * str , char key [][32 ], int mode );
68+ void get_magick (void );
6869
6970prefstruct prefs ;
7071
@@ -485,8 +486,7 @@ Update various structures according to the prefs.
485486void useprefs (void )
486487
487488 {
488- FILE * testfile ;
489- char teststr [80 ],str [80 ],
489+ char str [80 ],
490490 * pstr ;
491491 int i , flag ;
492492#ifdef USE_THREADS
@@ -681,19 +681,9 @@ void useprefs(void)
681681 if (flag && prefs .ncplot_name != prefs .ncplot_type )
682682 error (EXIT_FAILURE , "*Error*: CHECKPLOT_NAME(s) and CHECKPLOT_TYPE(s)" ,
683683 " are not in equal number" );
684- /* Deactivate antialiasing if the convert tool is not available */
685- if (prefs .cplot_flag && prefs .cplot_antialiasflag )
686- {
687- if ((testfile = popen ("convert" , "r" )))
688- {
689- fgets (teststr , 80 , testfile );
690- if (!strstr (teststr , "ImageMagick" ))
691- prefs .cplot_antialiasflag = 0 ;
692- pclose (testfile );
693- }
694- else
695- prefs .cplot_antialiasflag = 0 ;
696- }
684+ /* Deactivate antialiasing if the magick/convert tool is not available */
685+ if (flag )
686+ get_magick ();
697687
698688/* S/N thresholds */
699689 if (prefs .sn_thresh [1 ]< prefs .sn_thresh [0 ])
@@ -703,6 +693,40 @@ void useprefs(void)
703693 }
704694
705695
696+ /***i** get_magick ***********************************************************
697+ PROTO void get_magick(void)
698+ PURPOSE Get the name of an ImageMagick executable
699+ INPUT -.
700+ OUTPUT Executable filename.
701+ NOTES -.
702+ AUTHOR E. Bertin (CEA/AIM/UParisSaclay)
703+ VERSION 09/04/2025
704+ */
705+ void get_magick (void ) {
706+ FILE * testfile ;
707+ static char exec_names [][MAXCHAR ] = {"magick" , "convert" , "" },
708+ teststr [80 ];
709+ int i ;
710+
711+ prefs .cplot_antialiasexec = NULL ;
712+ for (i = 0 ; * exec_names [i ]; i ++ ) {
713+ sprintf (teststr , "%s 2>/dev/null" , exec_names [i ]);
714+ if (!(testfile = popen (teststr , "r" )))
715+ continue ;
716+ fgets (teststr , 80 , testfile );
717+ pclose (testfile );
718+ if (!strstr (teststr , "ImageMagick" ))
719+ continue ;
720+ prefs .cplot_antialiasexec = exec_names [i ];
721+ break ;
722+ }
723+
724+ if (!prefs .cplot_antialiasexec ) {
725+ prefs .cplot_antialiasflag = 0 ;
726+ warning ("ImageMagick package not found: " , "anti-aliasing de-activated in plots" );
727+ }
728+ }
729+
706730/********************************* endprefs *********************************/
707731/*
708732Mostly free memory allocate for static arrays.
0 commit comments