Reputation: 382
I wonder if it's not possible to give ImageMagick a hint what type the input string (or file) is.
E. g. treat .sql
as textfile.
I would need it to be used in php (Imagick).
The only thing I get is an exception that the file format is unknown:
no decode delegate for this image format `' @ error/blob.c/BlobToImage/361
Upvotes: 0
Views: 303
Reputation: 382
As @MarkSetchell mentioned you can tell ImageMagick the (custom) filetype by prefixing it.
FILETYPE:FILEPATH
eg
TXT:/path/to/file.sql
identify -list format
should give you that list of supported formats on linux$im = new Imagick("txt:/path/to/file.sql");
$im->readImageBlob(...)
)Upvotes: 1
Reputation: 207465
You can tell ImageMagick that a file contains text like this:
convert TEXT:stuff.sql result.png
which will give you an image of the contents of the text file stuff.sql
.
So, if you want an image of a directory listing, you can do:
ls -l | convert TEXT:- listing.png
Or, if you have some SQL in a file commands.sql
:
convert -background yellow -fill magenta text:commands.sql -trim result.png
Or, if you want it centred and with a larger border:
convert -background yellow -fill magenta text:commands.sql -trim \
-gravity center -extent 120%x120% result.png
Upvotes: 1