PHP - Convert PDF or ai file to svg file - pdf

I have a PDF file and an AI file and I want it to convert SVG.
I have installed PHP IMAGICK extension in my localhost and also installed the GHOSTSCRIPT.
code which I have tried is
$image = new Imagick();
$image->setResolution(1000,1000);
$image->readImage('C:\xampp\htdocs\project\test.pdf');
$color = $image->getImageColors();
$image->setBackgroundColor(new ImagickPixel('transparent'));
$image->scaleImage(600, 270);
$image->setImageFormat("svg");
$image->writeImage('C:\xampp\htdocs\project\test_convert.svg');
Following error is coming:
Fatal error: Uncaught ImagickException: PDFDelegateFailed `The system cannot find the file specified. ' # error/pdf.c/ReadPDFImage/794 in C:\xampp\htdocs\Project\Test.php:4 Stack trace: #0 C:\xampp\htdocs\Project\Test.php(4): Imagick->readimage('C:\xampp\htdocs...') #1 {main} thrown in C:\xampp\htdocs\Project\Test.php on line 4
I'm using Xampp and it has installed Imagick x86 (32 bits), so installing Ghostscript for 32 bits and tried 64 bits and also renamed gswin64.exe to gs.exe
Can anyone help me out to solve this error?

try the following code
$file= fopen('anycloud.ai', 'rb'); // pu here your ai or eps file
$img = new imagick(); // [0] can be used to set page number
$img->setResolution(300,300);
$img->readImageFile($file);
$img->setImageFormat( "jpg");
$img->setImageCompression(imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality(90);
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$img->writeImage('convert_jpg_from_ai.jpg');

Related

how to install Imagic in WAMP server?

I am getting error php_imagick.dll is not working. %1 is not a valid W32 application.
I am using WAMP Server Apaches 2.4.4.6 and PHP 7.4.9. my OS is windows 10 64bit. i think i download php_imagick-3.6.0rc2-7.3-nts-vc15-x64.zip file.
I have installed all DDL file in PHP7.4.9/ext/ and apply all process for install Imagic but still i am getting error
i have add extension in php.ini file.
enter image description here
Warning: PHP Startup: Unable to load dynamic library 'php_imagick' (tried: d:/wamp/bin/php/php7.4.9/ext/php_imagick (%1 is not a valid Win32 application.), d:/wamp/bin/php/php7.4.9/ext/php_php_imagick.dll (The specified module could not be found.)) in Unknown on line 0
i tried to find required file and package form
https://windows.php.net/downloads/pecl/releases/imagick/3.6.0rc2/ also checked
https://www.apachelounge.com/viewtopic.php?t=6359
but nothing helpful for me. that Module is not loading..
please help me....
check that the dll is not blocked:
try downloading the imagick threadsafe for here, version made for your PHP version
also install it from here on top of it all

How to fix "Cannot find a valid font for the family Sans' while adding text on image using react-native-ffmpeg

I am trying to add text on image using the code below
RNFFmpeg
.execute(`-y -i ${input} -vf "drawtext=text='Hello World':fontcolor=white:fontsize=75:x=0:y=0" ${output}`);
I am not using any custom font but still get this error.
Error:
[Parsed_drawtext_0 # 0x7f87a1ce40] Cannot find a valid font for the family Sans
index.js:115 [AVFilterGraph # 0x7f6765e760] Error initializing filter 'drawtext'
index.js:115 [AVFilterGraph # 0x7f6765e760] with args 'text=Hello World:fontcolor=white:fontsize=75:x=0:y=0'
index.js:115 [AVFilterGraph # 0x7f6765e760]
index.js:115 Error reinitializing filters!
index.js:115 Failed to inject frame into filter network: No such file or directory
index.js:115 Error while processing the decoded data for stream #0:0
Note:
I also tried using a custom font but not able to do it.
When I use RNFFmpegConfig.setFontDirectory('../../assets/fonts') function and with it the following code to add text on image
RNFFmpeg
.execute(`-y -i ${input} -vf "drawtext=text='Hello World':fontfile='../../assets/fonts/MyFont.ttf':fontcolor=white:fontsize=75:x=0:y=0" ${output}`);
It gives me the same error.
How can I fix this issue.
according to this
https://github.com/tanersener/ffmpeg-kit/wiki/Tips
you should registering the fonts under a directory using the FFmpegKitConfig.setFontDirectory methods or by specifying your own fontconfig configuration using FFmpegKitConfig.setFontconfigConfigurationPath
System fonts on Android are stored under the /system/fonts folder
and on iOS are stored under the /System/Library/Fonts

Fastlane upload to crashlytics fails with error fetching remote file

My Error :
Fastlane upload to crashlytics fails with the following error :
[12:59:37]: Error fetching remote file: Exit status of command 'unzip
'C:/Users/xxxx/Library/CrashlyticsAndroid/crashlytics-devtools.zip' -d
'C:/Users/xxxx/Library/CrashlyticsAndroid'' was 2 instead of 0.
Archive: C:/Users/xxxx/Library/CrashlyticsAndroid/crashlytics-devtools.zip
warning [C:/Users/xxxx/Library/CrashlyticsAndroid/crashlytics-devtools.zip]: 30829 extra bytes at beginning or within zipfile (attempting to process anyway)
file #1: bad zipfile offset (local header sig): 30829 (attempting to re-compensate)
inflating:
C:/Users/xxxx/Library/CrashlyticsAndroid/crashlytics_build.xml
error: invalid compressed data to inflate bad CRC 00000000 (should
be 313e1340)
file #2: bad zipfile offset (local header sig): 839 (attempting to re-compensate)
file #2: bad zipfile offset (local header sig): 839
file #3: bad zipfile offset (local header sig): 34909
Fastlane env : my fastlane environment is here https://github.com/fastlane/fastlane/issues/12161
fastlane is not officially supported on Windows (yet). My suggestion is to do this on macOS. (I also commented this on your GitHub issue).
Download the zip from here and extract where fastlane fails to unzip crashlytics-devtools.zip.
For me the path is C:/Users/{your-user}/Library/CrashlyticsAndroid/crashlytics-devtools.zip

affdex VideoDetector failed to open a mp4 file

I'm new to the library and I'm writing a program to analyze videos following the tutorial. Here is my code snippet:
detector = new VideoDetector(24);
detector.setClassifierPath(classifierPath);
detector.setImageListener(this);
detector.setDetectAllExpressions(true);
detector.setDetectAllEmotions(true);
detector.setDetectAllEmojis(true);
detector.setDetectAllAppearances(true);
detector.setDetectAge(true);
detector.setDetectEthnicity(true);
detector.start();
detector.process("path to the video file");
I got the following exception:
Error opening video file:
Source: __cdecl FileVideoCapture::FileVideoCapture(const class boost::filesystem::path &,const float)(C:\Jenkins\workspace\affdexface-win64\src\modules\utils\FileVideoCapture.cpp LINE 12)
I'm not sure where does the "C:\Jenkins\workspace\" part come from? Could anyone help me?
Thanks!
Can you paste more information on the codec of the video file. Here are couple of ways in which you can find the codec information.
Can you verify the version of opencv_ffmpeg*.dll? In the SDK installer under Affectiva->AffdexSDK->bin we include either opencv_ffmpeg248 or opencv_ffmpeg248_64.dll based on x86 or x64. Can you verify that you are getting the error using the dll that is shipped?
Did you convert the video to a different file format using ffmpeg and then re-run the application?

PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0

Ubuntu 16.04
PHP 7.0.4
Phalcon 2.1.x
Zephir
$~: php -v
PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0
When add phalcon.so in php.ini
Somehow I found the answer on and old bug report here:
Segmentation fault after update to 2.1.x
The problem is that the phalcon extension is being loaded before the json extension, so I guess that you, as myself, added the extension=phalcon.so line in the main php.ini
What you have to do is add a file in /etc/php/7.0/mods-available called phalcon.ini with the line in it: extension=phalcon.so
Then you just go and make a softlink that points from /etc/php/7.0/cli/conf.d/50-phalcon.ini to that phalcon.ini file, (important to put a number higher than 20 so it gets loaded after the json extension) and that's it!
Repeat the process to any other configuration that you have for php (apache, nginx, etc).