As we know the function getimagesize() works very good for images and swf files.
But it doesn't support shockwave file (.dcr).
SO, how can I get the width and the height of such file..
I am not Lingo/Director expert, but AFAIK you won't be able to do this from PHP.
.DCR file format is not open so you won't find file format specification for you to make your own parser and extract that info on your own.
However, there should be way to do this using director movie on client side.
Eg. You load external dcr file inside your own director movie (then you will be able to read width/height etc of loaded file). Your own director movie then updates some database with info on that specific loaded file so you can show width/height later on.
I've found this artice dating back to 2006 where this guy suggests the same thing:
http://director-online.com/forums/read.php?1,20621,20621,quote=1
Good luck mate! :)
If you have a windows server, you could install IrfanView (free) and use it from the command line (yes, it's free and has a command line) to convert the swf to dcr. (Surely there is a similar tool for Linux).
Convert images on the command line with IfranView
To call OS command line from php, use shell_exec().
Then you could read the swf image size with php normally.
Hope this helps
Related
Here is the code I used to convert my docx files to PDF:
<?php
require_once 'vendor/autoload.php';
use PhpOffice\PhpWord\IOFactory as WordIOFactory;
use PhpOffice\PhpWord\Settings;
// Set PDF renderer.
// Make sure you have `tecnickcom/tcpdf` in your composer dependencies.
Settings::setPdfRendererName(Settings::PDF_RENDERER_TCPDF);
// Path to directory with tcpdf.php file.
// Rigth now `TCPDF` writer is depreacted. Consider to use `DomPDF` or `MPDF` instead.
Settings::setPdfRendererPath('vendor/tecnickcom/tcpdf');
$phpWord = WordIOFactory::load('test/graph.docx', 'Word2007');
$phpWord->save('graph.pdf', 'PDF');
This code worked, but the problem was when it converted the file to PDF. The colors of the graphics were all lost and I feel like even the format was lost.
Here is the PDF file I had:
This picture shows the PDF file I had.
Here is the result after converting the DOCX file to a PDF file:
This picture shows the result after converting the DOCX file to a PDF file.
As you can see. The PDF file has lost the colors of the graphics. Who then, I would like to know from you. Do you have an idea to at least take into account the colors of the graphics? I have done a lot of research but have not found anything concrete. Can you help me please?
Well, I am doing my best to explain my problem. I hope I will get some nice answers. :)
Thank you for helping me. :)
I believe the OfficeConverter library will definitely helps you in what you're going to achieve, which it is actually utilising the libreoffice way mentioned by KJ.
I downloaded your graph.docx file and tested, the result should be what you're looking for. I have a demo site for you to test out, feel free to try it out, it is my open source project.
Here the link to the site PhpOfficeTemplate.
Do remember to Enable the Office Converter options.
Then select your docx file in the Template.
Hope it helps !
Microsoft Word has many proprietary features that cannot readily be carried over from conversion from DocX to simpler Rich Formats. This can be seen in Microsoft's own applications too. Very simply open a DocX in the native Write.exe here we see complex styles are unsupported.
It is thus not surprising that the only App that can faithfully convert Word Documents to PDF is MS Word export to PDF (Similar when converting PDF "To" DocX), and many converter programs/scripts can invoke an installed MS Office by calling Microsoft "Interop" DDLs.
Adobe Online Converter uses copies of MS Word as can be seen when using their conversion apps:-
Similar with other brand leading converters here Aspose clearly use MS Word
File: graph (1).pdf
...
Application: Microsoft Office Word
PDF Producer: Aspose.Words for .NET 22.11.0
PDF Version: 1.7
File Size: 7.07 KB (7,237 Bytes)
Number of Pages: 1
Page Size: 21.0 x 29.7 cm (A4)
Bottom line for docX fidelity you need a running copy of MS word
Next best
You can sometimes get close (but not always) using Libre Office or a variant so that chart works well using Server conversion. However, note the significant increase in size (over 10x bigger) to embed different MS aspects.
File: graph (2).pdf
...
Application: Writer
PDF Producer: ConvertAPI
PDF Version: 1.7
File Size: 93.37 KB (95,607 Bytes)
Number of Pages: 1
Page Size: 21.0 x 29.7 cm (A4)
You can better that (only 5 times bigger) by using a batch with local current 7.4
libreoffice\program>soffice --convert-to pdf *.docx
"The program script" as shown above, will start soffiice in the library\program folder, to convert every local docx into a local pdf.
If you need to customise, i.e. where you start it as a CWD, or run one by one files elsewhere, then that will be specific to your operating system and workflow, mine is just run one single line (or a few) as a full blown suite of commands, = power via one line simplicity.
There are 100's of variants of php aids and many to run and install libre office so try searching say github.com/search?q=php+libreoffice, a good example is the one shown by #zeikman
$converter->convertTo('output-file.pdf'); //generates pdf file in same directory as test-file.docx
I am using some software built with php. Its for a car dealership website.
rpnmotorsinc.net
The problem is being able to upload images. If I upload most jpg or jpeg files, they usually upload with no problem. Since my client does not want to resize/resave images, he is wanting to take photos directly from his Canon camera to the computer to upload to website, again without having to resize or resave. These images range from 3 to 4 MB in size.
Here is the error message I receive while trying to upload these images:
Warning: exif_read_data(IMG_7B78AC-0BE18D-FEEBCB-6DED45-5C0BF2-780393.jpg): IFD data bad offset: 0xFFFFFD10 length 0x0ED42
The images seem to upload, but they throw errors and it seems to take a while to upload. I know they are large in file size, but what I am expecting is a little faster upload and to not show any errors.
Here is my php/server info https://rpnmotorsinc.net/phpinfo.php
How can I fix this?
I do have the same issue with a phpBB bulletin board.
I added a routine to rotate and resize pictures at upload. Works like a charm except with original canon photos.
I have to change the exif-data and save the picture - then it works.
I know, this isnĀ“t a solution, but maybe it helps finding one.
This seems to relate to a known bug of PHP. I found a solution using ExifTool before uploading a picture that generated this error:
exiftool -X photo.jpg > photo.xml
exiftool -tagsfromfile photo.xml -all:all photo.jpg
1 image files updated
The first command saves the EXIF metadata to a separate XML file, and the second reconstructs them from there. This is obviously not a good solution for the original question because it requires even more work from your customer than just resizing the picture. If you can install ExifTool on your server, however, you may be able to run it after any new upload.
As I Upload the file using php, it should move to conversion tools and the output, i.e. a file in a *.swf format, should be uploaded to the same directory, where my original file exists and should be displayed in my website.
I have searched long and I got swftool, but it's not working on my linux machine.
Converting every format is not possible. Your lazy question is a bit broad there.
As alternative to swftool you can however utilize OpenOffice/LibreOffice. The Impress presentation module allows to export .swf animations. LibreOffice can be utilized from the commandline (thus via php).
soffice -headless -convert-to swf animation.ppt
You can google other examples.
The actual task then becomes to create a Powerpoint or Impress document first (it's an XML format) from whatever input and media files you have. (Maybe a simple .SMIL works too.)
You still can convert any document to SWF if it can be printed. As almost any kind of document can be printed, it is possible to convert them to SWF. In order to achieve this you need to use a virtual SWF printer software, e.g. Print2Flash (www.print2flash.com). The PHP code is quite simple:
$p2f = new COM("Print2Flash4.Server2");
$p2f->ConvertFile($sourcefile,$outfile);
$sourcefile is the path and name of the source document, e.g. a PDF or Office document. $outfile is the name of the output SWF file. more details can be got from php sample from the SDK that can be downloaded from http://print2flash.com/download.php
I'm trying to take a generated html file and convert it to PDF on the fly with PHP.
It's going on my localhost and staying there so for the PDF conversion I'm using a Mac OSX utility, I guess you would call it.
The terminal command being:
/System/Library/Printers/Libraries/convert -f temporary.html -o destination/final.pdf
This works properly via terminal (produces a simple 20kb PDF file); however, when I run it inside PHP via passthru() the file (final.pdf) is created though it is a Zero KB file (corrupt).
The /destination folder is CHMOD 777, temporary.html is CHMOD 755.
Any help would be greatly appreciated.
Edit (Additional Detail):
Now in the error log, amongst the debug lines there is an error of "ERROR: xhtmltopdf (PID 13204) crashed on signal 6!"
I like to share what I do to generate PDF file on the fly. We use UNIX server to host.
I use tcpdf - a php library to convert HTML to PDF file. I use it in my projects and it works very well. TCPDF supports css, javascript, forms, images and lot more.
Website: http://www.tcpdf.org/
Demos: http://www.tcpdf.org/examples.php
When I need convert HTML in PDF I use this very nice software: http://www.princexml.com
You could have a look, it's free for personal use.
I have to make thumbnails from banners in swf file format (flash 9). I want to use php, but if that's not possible anything which work in a linux command line is fine by me.
I tried to open them with ffmpeg-php, but it says: Can't open movie file /where/the/file/is
The file is there and is readable by the user.
Any ideas?