Is it possible to write directly to a db?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jack-mann
Posts: 16
Joined: 2014-03-15T00:49:44-07:00
Authentication code: 6789

Is it possible to write directly to a db?

Post by jack-mann »

Code: Select all

convert large.png -crop 256x256 -set "filename:t" "%[fx:page.x/256]_%[fx:page.y/256]" +repage +adjoin PNG8:'.$workDir.'"/img_%[filename:t].png"
Can I somehow skip the writing to the filesytem and plug in to imagemagick and write directly to a database?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Is it possible to write directly to a db?

Post by snibgo »

If you have a command that takes an image and puts it into a database, then you could put that into delegates.xml. However, I don't see how you could specify which database, or how you would specify the key to the record you want to insert or update.
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Is it possible to write directly to a db?

Post by dlemstra »

You should probably also read the following post: http://stackoverflow.com/questions/3748 ... yea-or-nay. It has some great information about the pros and cons of storing images in a database.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jack-mann
Posts: 16
Joined: 2014-03-15T00:49:44-07:00
Authentication code: 6789

Re: Is it possible to write directly to a db?

Post by jack-mann »

thanks In my use case it does make sense since I am using SQLite and am transferring the db over the net...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible to write directly to a db?

Post by fmw42 »

I think you may be able to do it with PHP as an intermediary. It can execute IM commands and also talk to SQL. But you still may have to create a physical file on disk.
jack-mann
Posts: 16
Joined: 2014-03-15T00:49:44-07:00
Authentication code: 6789

Re: Is it possible to write directly to a db?

Post by jack-mann »

that's what I am actually doing. I am calling convert from php. But since this is a server app with lots of io load it would be nice if I could save my script from generating those tmp files
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible to write directly to a db?

Post by fmw42 »

Ask you question on the developers forum and see if the IM developers can help.

But IM still will create tmp files to hold intermediate results from any complex command line. The only possible thing you might be able to save is the result, if the developers know of a way to write it directly to your database rather than the disk and subsequently copy it to database.

I really do not know.
jack-mann
Posts: 16
Joined: 2014-03-15T00:49:44-07:00
Authentication code: 6789

Re: Is it possible to write directly to a db?

Post by jack-mann »

I am afraid if I ask such a question on the dev forum the guys will make fun of me ....
I quess it is just not possible
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Is it possible to write directly to a db?

Post by magick »

You cannot connect to a database, currently, from the command line. However, from a program you can call ImageToBlob() or ImagesToBlob() and write the blob to the database. These are MagickCore method. However, there are analogs in other languages such as Magick++, PerlMagick, etc.
Post Reply