imagemagick - Magick++: Image -> draw() problems when drawing text -


i complied imagemagick-6.8.8 on mac 10.9.2 static libraries support magick++.

now trying execute following example magick++ tutorial pdf on page 19 ( have removed comments following code

    drawabletext::drawabletext(double x, double y, const string& text_to_write)     image my_image(geometry(320,220), color("white"));      list<drawable> text_draw_list;     text_draw_list.push_back(drawablefont("-misc-fixed-medium-o-semicondensed—13-*-*-*-c-60-iso8859-1"));     text_draw_list.push_back(drawabletext(101, 50, "text write on canvas"));     text_draw_list.push_back(drawablestrokecolor(color("black")));     text_draw_list.push_back(drawablefillcolor(color(0, 0, 0, maxrgb)));      my_image.draw(text_draw_list); 

i following error:

magick: non-conforming drawing primitive definition `text' @ error/draw.c/drawimage/3193 

can me figure out.

also cannot use annotate have not compiled x support in libraries , believe using annotate requires x...

here output configure command

                  option                        value ------------------------------------------------------------------------------- shared libraries  --enable-shared=no        no static libraries  --enable-static=yes       yes module support    --with-modules=no     no gnu ld            --with-gnu-ld=no      no quantum depth     --with-quantum-depth=16   16 high dynamic range imagery                   --enable-hdri=no      no  install documentation:      yes  delegate configuration: bzlib             --with-bzlib=yes      yes autotrace         --with-autotrace=no       no dejavu fonts      --with-dejavu-font-dir=default    none djvu              --with-djvu=yes       no dps               --with-dps=yes        no fftw              --with-fftw=yes       no flashpix          --with-fpx=yes        no fontconfig        --with-fontconfig=yes     no freetype          --with-freetype=yes       no ghostpcl          none              pcl6 (unknown) ghostxps          none              gxps (unknown) ghostscript       none              gs (unknown) ghostscript fonts --with-gs-font-dir=default    none ghostscript lib   --with-gslib=no       no graphviz          --with-gvc=no      jbig              --with-jbig=yes       no (failed tests) jpeg v1           --with-jpeg=yes       yes jpeg-2000         --with-jp2=        lcms v1           --with-lcms=yes       no lcms v2           --with-lcms2=yes      no lqr               --with-lqr=yes        no ltdl              --with-ltdl=yes       no lzma              --with-lzma=yes       yes magick++          --with-magick-plus-plus=yes   yes mupdf             --with-mupdf=no       no openexr           --with-openexr=yes        no openjp2           --with-openjp2=yes        no pango             --with-pango=yes      no perl              --with-perl=no        no png               --with-png=yes        yes rsvg              --with-rsvg=no        no tiff              --with-tiff=yes       yes webp              --with-webp=yes       no windows fonts     --with-windows-font-dir=  none wmf               --with-wmf=no     no x11               --with-x=no           no xml               --with-xml=yes        yes zlib              --with-zlib=yes       yes  x11 configuration:       x_cflags        =        x_pre_libs      =        x_libs          =        x_extra_libs    =   options used compile , link:   prefix          = /users/awais/downloads/image_magick/imagick/im   exec-prefix     = /users/awais/downloads/image_magick/imagick/im   version         = 6.8.8   cc              = clang   cflags          = -arch x86_64 -wall -fexceptions -d_fortify_source=0 -d_thread_safe -pthread -dmagickcore_hdri_enable=0 -dmagickcore_quantum_depth=16   cppflags        = -i/users/awais/downloads/image_magick/imagick/im/include/imagemagick-6   pcflags         = -dmagickcore_hdri_enable=0 -dmagickcore_quantum_depth=16   defs            = -dhave_config_h   ldflags         = -l/users/awais/downloads/image_magick/imagick/im/tmp/lib -arch x86_64 -l/users/awais/downloads/image_magick/imagick/imagemagick-6.8.8-10/magick -l/users/awais/downloads/image_magick/imagick/imagemagick-6.8.8-10/wand -l/opt/local/lib   magick_ldflags  = -l/users/awais/downloads/image_magick/imagick/im/lib -l/users/awais/downloads/image_magick/imagick/im/tmp/lib -arch x86_64 -l/users/awais/downloads/image_magick/imagick/imagemagick-6.8.8-10/magick -l/users/awais/downloads/image_magick/imagick/imagemagick-6.8.8-10/wand -l/opt/local/lib   libs            = -ltiff -ljpeg -lpng16 -l/opt/local/lib -llzma -lbz2 -lxml2 -lz -lm   cxx             = clang   cxxflags        = -arch x86_64 -d_thread_safe -pthread   features        = dpc   delegates       = bzlib mpeg jng jpeg lzma png tiff xml zlib 

it'll save lot of trouble installing fontconfig, freetype & ghostscript. have x11 sitting in systems /opt directory. if not, jump on xquartz , run .dmg install. dejavu & window's fonts nice have, not needed. after installing font libraries, you'll need re-configure imagemagick (remember make clean), , re-install.

for magick++ tutorial, following line bit confusing, involves few wildcards may not familiar with.

drawablefont("-misc-fixed-medium-o-semicondensed—13-*-*-*-c-60-iso8859-1") 

from api, may better introduction initialize font directly.

magick::drawablefont::drawablefont  ( const std::string & family_,                                       magick::styletype   style_,                                       const unsigned int  weight_,                                       magick::stretchtype stretch_                                      ) 

find typeface wish use running identify -list font

font: helvetica-narrow   family: helvetica narrow   style: normal   stretch: condensed   weight: 400   glyphs: /usr/local/share/ghostscript/fonts/n019043l.pfb  

then it's matter of applying correct parameters

drawablefont font = drawablefont("helvetica narrow",                                   normalstyle,                                   400,                                   semicondensedstretch                                  ); text_draw_list.push_back(font); text_draw_list.push_back(drawabletext(101, 50, "text write on canvas")); text_draw_list.push_back(drawablestrokecolor(color("black"))); text_draw_list.push_back(drawablefillcolor(color(0, 0, 0, maxrgb)));  my_image.draw(text_draw_list); 

example text write on canvas


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -