The Image Magic font does not apply - reactjs

In my project, I draw a certificate using the shell, on the background image I put all 3 lines. I manage to apply different colors to them, font size, but I can't use different fonts.
shell.exec(
`convert ${certificateImage} -resize 800x600 \
-gravity south \
-fill blue -font Candice -pointsize 60 -annotate +0+190 '${certificateHeader}' \
-fill black -font Candice -pointsize 40 -annotate +0+190 '${certificateTxt}' \
-fill red -font SheerBeauty -pointsize 20 -annotate -100+40 '${nextCertNumber}' \
${thumbnailsFolder}/${certificateId}.png`,
{async: true},
() => log('thumbnail created successfully'),
);
What am I doing wrong? I would be grateful for any answer. I watched imagemagic, but so far nothing is working.

Related

Create endless loop animation using ffmpeg using only certain frames

I can create an animated gif using the commands below.
ffmpeg -i wrist_0001.png -vf palettegen=16 palette.png
ffmpeg -i wrist_%04d.png -i palette.png -filter_complex "fps=20,scale=720:-1:flags=lanczos[x];[x][1:v]paletteuse" logo.gif
What I'm trying to know how to do is:
Create another animated gif using just the first 20 frames and the animation loops endlessly (no pausing at the end of the animation).
Create another animated gif using just the first 20 frames where the animation plays then pauses at the end for 3 seconds then continues. (endlessly) Example: (play animation - pause 3 seconds - play animation - pause 3 seconds - play animation - pause 3 seconds...)
Note: I'm trying to avoid having to type in wrist_0001.png wrist_0002.png...is there away to do wrist_0001.png to wrist_0020.png?
Create another animated gif using just the first 20 frames and the animation loops endlessly (no pausing at the end of the animation):
ffmpeg -framerate 20 -i wrist_%04d.png -filter_complex "scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=16[p];[s1][p]paletteuse" -frames:v 20 -loop 0 20framesloop.gif
When using a set of images as the input set the frame rate with the -framerate image demuxer input option. Your original command is defaulting to 25 fps and then using the fps filter to convert to 20 fps meaning frames are being dropped.
-loop 0 is the default for the GIF muxer, but I added it to show how it works if you want to change the looping. 0 means infinite loop.
This example makes the GIF in one command as shown in How do I convert a video to GIF using ffmpeg, with reasonable quality?
Create another animated gif using just the first 20 frames where the animation plays then pauses at the end for 3 seconds then continues. (endlessly)
Most efficient method is to re-mux the GIF from the previous step:
ffmpeg -i 20framesloop.gif -c copy -final_delay 300 -loop 0 3secpause.gif
-final_delay 300 takes a value in centiseconds, so 3 seconds is 300 centiseconds. See ffmpeg -h muxer=gif for more info.

Converting PDF to PNG with same resolution - Imagemagick

I have 1000s of PDFs with multiple pages and each PDF has different resolution (based on scanners used to scan them). I want to convert each page of PDF to PNG to pass it to Tesseract for OCR. I used Imagemagick to convert to PNG but have to pass a fixed DPI for all images to get a good readable output. Is there a way I can convert each PDF by preserving the resolution of that PDF too?
For example, if 1.PDF has resolution 622 × 788 and 2.pdf has resolution 792 × 612, I want the exact conversion with same resoultion just a different format(PNG).
The command I am using right now is:
convert -monochrome -density 1200 input.pdf -resize 25% -monochrome -white-threshold 50% -black-threshold -50% output.png
Thanks,
pashah
Perhaps read the geometry of the first page, then resize all pages to match?
SIZE=$(identify -format '%g' input.pdf)
convert -monochrome \
-density 1200 \
-resize $SIZE \
-white-threshold 50% \
-black-threshold -50% \
-append \
output.png

play videos side by side MELT

I am having issues in playing videos side by side. Can someone help me?
I am observing for my MELT sequence 1 video is scaled properly, but other is cropped.
Please suggest solution. Here is my melt command.
melt A_David_Beckham.mp4 in=0 out=650 \
-track -blank 49 C_KindleTouch.mp4 in=0 out=650 \
-transition composite start=0/0:960x1080 end=0/0:960x1080 distort=1 a_track=1 b_track=0 \
-transition composite start=960/0:960x1080 end=960/0:960x1080 distort=1 a_track=0 b_track=1 \
-transition mix:-1 in=50 out=650 a_track=0 b_track=1
A_Backham is scaled properly starting 50th frame, but C_KindleTouch.mp4 is cropped.
Both videos are HD videos and having length > 650 frames.
You need to have a Blank track running through in order to achieve this feat.
Here is MELT command to play 2 videos below in parallel audio of 2nd video will play. Switch tracks in order to switch audio.
melt colour:black out=650 \
-track A_David_Beckham.mp4 in=0 out=650 \
-track C_KindleTouch.mp4 in=0 out=650 \
-transition composite start=0/0:960x1080 end=0/0:960x1080 distort=1 a_track=0 b_track=1 \
-transition composite start=960/0:960x1080 end=960/0:960x1080 distort=1 a_track=0 b_track=2
In case you need to implement a Credit Squeeze.. Here is a way...
(Movie channels typically has requirement to squeeze In End Credits on Left and Start Playing next movie on right)
time melt colour:black out=599 \
-track C_KindleTouch.mp4 in=0 out=299 C_KindleTouch.mp4 in=300 out=349 -attach volume:0.1 C_KindleTouch.mp4 in=350 out=599 \
-track -blank 49 B_Samsung.mp4 in=0 out=599 \
-transition composite start=0/0:1920x1080 end=0/0:960x1080 distort=1 a_track=0 b_track=1 in=50 out=99 \
-transition composite start=1920/0:960x1080 end=960/0:960x1080 distort=1 a_track=0 b_track=2 in=50 out=99 \
-transition mix:-1 in=50 out=99 a_track=0 b_track=2 \
-transition composite start=0/0:960x1080 end=0/0:960x1080 distort=1 a_track=0 b_track=1 in=100 out=299 \
-transition composite start=960/0:960x1080 end=960/0:960x1080 distort=1 a_track=0 b_track=2 in=100 out=299 \
-transition composite start=0/0:960x1080 end=-960/0:960x1080 distort=1 a_track=0 b_track=1 in=300 out=349 \
-transition composite start=960/0:960x1080 end=0/0:1920x1080 distort=1 a_track=0 b_track=2 in=300 out=349 \
-transition mix:-1 in=300 out=349 a_track=0 b_track=2 \
-consumer avformat:output-squeeze_nd_back_final_v6.ts vcodec=nvenc_h264 vb=5000k acodec=aac ab=256k mlt_image_format=yuv420p
This is how effect is working
Play Black or Blank screen on Track 0, Play Video 1 (End Credits part) on Track 1 , play video 2 on track 2
Squeeze in Video 1 from full screen to left half as you bring in Video 2 in right half, mix it
Play Both videos in parallel for some duration
Squeeze Out Video1 and Expand Video 2 to full screen

add text on 1st page of a pdf file

I'm tryin to add a text comment (not a note) to a pdf file.
I create a date.ps file with contains the text comment :
%!
/Arial findfont
30 scalefont
setfont
newpath
10 720 moveto
(PAID on 5.1.2013) show
showpage
and I launch the shell command with $i=name of the pdf file to tag:
gs -q -dNOPAUSE -dSAFER -dBATCH -sOutputFile=$RFP/$DOMAINE/$NEWNAME -sDEVICE=pdfwrite -sPAPERSIZE=a4 date.ps $i
This works, but it create a new 1st page empty with the text "PAID on 5.1.2013" alone.
I do not find the trick to overlay the text on the 1st page of the original pdf.
Can you help me pls
You can do this directly to the PDF using the free cpdf command line tools:
For example,
cpdf -add-text "PAID on 5.1.2013" -topleft 100 -font "Helvetica" -font-size 30 in.pdf -o out.pdf
Since cpdf has a strange license for commercial use, I tried to find an alternative. Here is one (you need to install enscript, ps2pdf and (pdftk or qpdf)). The idea is just to use enscript to create a .ps from a text, then you convert this .ps into a .pdf using ps2pdf, and then you stack it on top of the original pdf with pdftk or qpdf...).
pdtfk version:
echo "I will be stamped on top of the page" | \
enscript -B -f Courier-Bold16 -o- | \
ps2pdf - | \
pdftk input.pdf stamp - output output.pdf
qpdf version:
If you want the text to repeat on all pages:
tmpfile=$(mktemp) && echo "I will be stamped on top of the page" | \
enscript -B -f Courier-Bold16 -o- | \
ps2pdf - "$tmpfile" && qpdf input.pdf --overlay "$tmpfile" --repeat=1-z -- output.pdf
if you just want to put it on the first page:
tmpfile=$(mktemp) && echo "I will be stamped on top of the page" | \
enscript -B -f Courier-Bold16 -o- | \
ps2pdf - "$tmpfile" && qpdf input.pdf --overlay "$tmpfile" -- output.pdf
See the enscript documentation for more options on how to format the text.
NB: mktemp is just used to create a temporary file to provide a one-liner solution, since qpdf does not accept input from stdin. Remove the tmpfile with rm "$tmpfile" after the command is done.
Because your PostScript executed a showpage it ejects the first page after marking it, so the remaining content is therefore on the 2nd and subsequent pages. If you don;t execute showpage then the marks you make will be on the first page, and the first PDF page will be drawn 'on top' of it.
More complex code can use BeginPage and EndPage to draw over and under the page contents, and to do so on specified pages, among other things.
[added later]
Try this:
%!
<<
/EndPage
{
0 eq
{
0 eq
{
/Arialabold findfont 22 scalefont setfont newpath 250 820 moveto 1 0 0 setrgbcolor (PAYE PAR CCP LE $DATEPMT) show
} if
true
}
{
pop false
} ifelse
} >> setpagedevice
Works for me.

Can't seek beyond downloaded data in some H.264 videos in Silverlight

The project I'm currently working on is using a Silverlight based player to stream wmv videos encoded through WME.
However we want to be able to move away from Silverlight in the future and to the video tag in HTML5, so we need to encode our videos to H.264 in an mp4 container.
Everything is fine except for on small problem, it's not possible to seek beyond what has been downloaded, at least not on lower quality encodes.
One of our test files is an HD wmv video, which we encode down to 2 Mbit, 1 Mbit and 0.5 Mbit using FFmpeg, and mp4box to reorder the moov atoms.
In both the 2 and 1 Mbit encodes the Silverlight MediaElement recognizes a seek beyond what's downloaded as we'd like it to, and requests video data and starts playing from the seek point.
However, with the 0.5 Mbit video that doesn't happen, and instead the video freezes while it keeps downloading the video normally.
Using a low-quality H.264 video from Youtube works, so I don't know if it's the parameters to FFmpeg that's the problem or something else.
Here's the encoding command-line:
ffmpeg -y -i fooHD.wmv -an -vcodec libx264 -vpre slow -level 41 -b 2000k -bufsize 20000k -maxrate 25000k -g 250 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +dct8x8+bpyramid -me_method umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 -threads 0 -pass 1 -f rawvideo nul
ffmpeg -y -i fooHD.wmv -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -vpre slow -level 41 -b 2000k -bufsize 20000k -maxrate 25000k -g 250 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +dct8x8+bpyramid -me_method umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 -threads 0 -pass 2 bar2000k.mp4
ffmpeg -y -i fooHD.wmv -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -vpre slow -level 41 -b 1000k -bufsize 20000k -maxrate 25000k -g 250 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +dct8x8+bpyramid -me_method umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 -threads 0 -pass 2 bar1000k.mp4
ffmpeg -y -i fooHD.wmv -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -vpre slow -level 41 -b 500k -bufsize 20000k -maxrate 25000k -g 250 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +dct8x8+bpyramid -me_method umh -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 -refs 6 -deblockalpha 0 -deblockbeta 0 -threads 0 -pass 2 bar500k.mp4
mp4box.exe -inter bar2000k.mp4
mp4box.exe -inter bar1000k.mp4
mp4box.exe -inter bar500k.mp4
fooHD.wmv is 2:17 long and running at 8 Mbit/s # 29.97 fps.
My throught immediately goes to an issue related to a lack of keyframes, but I see -g 250 for all your encoding settings. However based on some past issues with encoders getting fast and loose with I-frame settings at low bandwidth I still suggest reading back the I-frame/keyframe stats to see if your 500k file is not being encoded the way you asked.

Resources