I installed the RFD ImageMagick Library using
composer require rfd/imagemagick
I went through the readme and this is how they have done it
use Rfd\ImageMagick;
use Rfd\ImageMagick\CLI\OperationFactory();
use Rfd\ImageMagick\Image\File;
use Rfd\ImageMagick\Options\CommonOptions;
$im = new ImageMagick(new OperationFactory());
It throws Class 'Rfd\ImageMagick' not found error. But that error goes away when I do
use Rfd\ImageMagick\ImageMagick;
The statement below throws an error but works with the () at the end
use Rfd\ImageMagick\CLI\OperationFactory();
Now its giving OperationFactory not found error. I can't find that class anywhere in the install so I'm really confused! Any help would be really appreciated. I'm trying to generate PDF thumnail image previews using this library.
Thanks to emcconville, I contacted the author. This works
use Rfd\ImageMagick\ImageMagick;
use Rfd\ImageMagick\CLI\Operation\Factory as OperationFactory;
Related
I have just upgraded a net451 classic dotnet project to multi-target project using net461/netstandard2.0 with reasonable success.
Did however come across this compiler error for net461 when it comes to gaining access legacy configuration files via:
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
This appears to not be a thing in netstandard2.0 :) Anyone know of any work arounds or good solutions?
Add the ConfigurationManager as a NuGet
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
</ItemGroup>
Use ConfigurationManager in C#
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Log4NetLogger.Configure(configFile.FilePath);
According to this article, which I found when looking for replacement for PlatformServices.Default.Application.ApplicationBasePath, it should be either of:
AppDomain.CurrentDomain.SetupInformation.ApplicationName
Assembly.GetEntryAssembly().GetName().Name
Just like you, I've just found out that the first one does not exist in recent 2.0 so I'll be using the GetEntryAssembly name..
..however keep in mind that GetEntryAssembly may be null when used i.e. from within a test runner like xUnit, or probably will be wrong if your appcode is ran from another not-yours hosting/startup module, etc - so that is not a perfect replacement.
I can't seem to find a solution to access a MySQL server from an Objective-C Mac OS project (which uses ARC).
I tried to use the MySQL framework that Sequel Pro provides, but that crashes (EXC_i386_GPFLT) my App whenever I just create a connection object:
SPMySQLConnection *conn = [[SPMySQLConnection alloc] init];
I don't know whether that is a bug in the framework or if I need to do something else in order to use it.
I tried a few other libraries (like MySqueakQl) but none of them are ARC compatible.
Also I tried to link to libmysqlclient.a directly, but if I copy that library into my project, I get a code signing error; if I just link to the .a in /usr/local/mysql/lib/, I get another error: dyld: Library not loaded: libmysqlclient.18.dylib ... Reason: image not found. I have to admit that I have zero experince with using third-party libraries (whether .a or .dylib) and probably didn't do it right.
I'm a bit surprised that there doesn't seem to be an up-to-date (read: working) solution out there. I know, consumer apps rather use Core Data, but I have to access out company database server.
Has anybody seen a solution (libary?) that works more or less "out of the box"? I'd be willing to pay for something that actually works.
A good tutorial on how to use .a libraries in Xcode projects that would also help me to understand where the dylib error comes from would also be very helpful.
Problem solved. I probably made some mistake when including the library.
The right steps to do this:
Drag the libmysqlclient.a library into your project window
Make sure you set Copy items if needed to Yes, and that it is added to your main target
Drag a folder containing the headers (found under /usr/local/mysql/include) into your project window
Again, make sure you set Copy items if needed to Yes and the correct target is checked.
Then:
#import "mysql.h"
- (BOOL) mySQLTest {
MYSQL connection;
mysql_init(&connection);
if(!mysql_real_connect(&connection,
[self.host UTF8String],
[self.user UTF8String],
[self.password UTF8String],
[self.database UTF8String],
self.port,
NULL,
0)) {
return NO;
}
// ... work with the DB
mysql_close(&connection);
return YES;
}
Works like a charm.
I have no idea why on my former attempts I got an error about the dylib; I never used it (only the static library).
The code signing issue may have been just a bug or one-time quirk in Xcode.
I'm currently develop an Objective-C library that links to the MariaDB C connector. I believe there is a problem with the library, though.
Every time I execute my code I get very strange errors on the console. The -(id)init method of my library calls mysql_init(NULL) to initialise the library but as soon as I return from -(id)init I get the following errors in the console:
Object 0x10643df70 of class XXX autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Thing is, there is no multithreaded code being executed and if I run the same - (id)init without the call to mysql_init(NULL) the errors disappear. I believe the libmariadb library is causing these errors to appear. I don't get why though.
Do I need to build it with any special command line switches? Am I calling the right methods? I obviously used the MySQL online documentation as a guide.
Make sure you add this anytime you have a new thread:
#autoreleasepool {
//enter code here
}
Have you tried latest revision from launchpad?
Also try to build libmariadb with -DUNDEF_THREADS_HACK and
CMAKE_USE_PTHREADS:BOOL=OFF)
I was busy with other stuff for a while. I've since updated MariaDB to the latest version and, as far as I can tell, it works fine.
I'm desperately trying to send a message as JSON to a PHP script.
destination d_php {
program("/usr/bin/php -f /data/htdocs/log.php" template("$(format-json)\n") ) ;
};
The php script is fine. Using simple macros works well, but the "format-json" function does always return this:
error in template: $(format-json)
I tried everything I could find in the documentation, but all response I get is "error in template". The official docs (link) even use 2 different spellings, not very promising.
Any ideas?
the format-json and format_json syntax should both work, hyphens and underscores are equivalent in syslog-ng.
As for the actual problem, have you tried setting the scope parameter of format-json, like "$(format_json --scope selected_macros)"? By default, it is empty, which means there is nothing to format.
HTH,
Regards,
Robert Fekete
Found the reason. Apparently, syslog-ng is split into separate packages on Ubuntu (12). I had to install syslog-ng-mod-json.
It's really a shame that syslog-ng doesn't give the slightest hint that the function is missing or unknown, instead of some general error.
If you are compiling from the source, you shall install json-c library first (yum install json-c-devel).
So very strange issue. I only recently starting using auto loading in PHP 5.3+ and of course, this inevitably led to composer.
I did a really simple install with composer with only one package, php Image Workshop.
In addition to my own auto loader, I fire of the vendor/autoload.php
Then in my code:
use PHPImageWorkshop\ImageWorkshop;
$imagelayer = ImageWorkshop::initFromPath( $filename );
The namespace is valid and I get into the class which immediately throws an error.
PHP Fatal error: Call to undefined function PHPImageWorkshop\\imageCreateFromJPEG() in /var/www/html/vendor/sybio/image-workshop/src/PHPImageWorkshop/ImageWorkshop.php on line 55
imageCreateFromJPEG should be in the global namespace already, but the code in the class doesn't prefix it with a '\'.
Is this all right? I feel like I'm looking for a black cat in a dark room.
I guess the problem is GD is not available in your PHP instalation. Try to install php5-gd and it should work.
Good luck