When trying to import images, none of the alternative sized images are created.
Only the Original image is saved.
However, if I attach an image to a node, the alternative sizes are created.
The alternative sizes being thumbnail and preview.
Safe Mode is off.
Drupal 5.1
Image Magik is not installed.
I'm installed this module many times, but have not had this type of problem.
Any ideas?
Thanks in advance.

Comments

drewish’s picture

Status: Active » Postponed (maintainer needs more info)

when did you download the module? does the same error occur with the 1.4 release?

pelicani’s picture

I tried both version today and they produced the same results.
5.x-1.x-dev
5.x-1.4

drewish’s picture

i'm not really sure why that's happening. the import works fine for me... unless i can get some more detail or other people running into the same problem it's hard to figure out what's going on. if you want to install the devel module on your site and then create a logon for me i can get on your site and try look into it.

pelicani’s picture

Thanks for offering to debug, but I don't want to take up your time on this.
So I'll try to debug and ask you questions as I go.
My problems seems to stem from a problem with the original_path...
echo "-".$node->images[IMAGE_ORIGINAL]."
"; //returns as the location of the file I uploaded
$original_path = file_create_path($node->images[IMAGE_ORIGINAL]);
echo "-".$original_path."
"; returns blank
It seems that file_create_path cannot find the file.
I will continue to work on figuring this out, just wanted to post an update to one of my findings.
Thanks in advance.

pelicani’s picture

I couldn't figure out what changed, but the version I have been using, 5.x.1.0 works fine.
To make sure my server isn't the problem I got a copy of 1.0 and tested it and it works fine as well.
The difference between 1.4 and 1.0 must be documented somewhere, but I haven't seen it.
Would ya'll point me to where I could find out how to configure the latest.
I'd appreciate the assistance.
Thanks in advance.

drewish’s picture

Status: Postponed (maintainer needs more info) » Active

what do you mean by "returns as the location of the file I uploaded"? could you give me an example of one of the paths?

what's your drupal file path set to? what's your image file path set to?

pelicani’s picture

"returns as the location of the file I uploaded"?
I FTP files to the '/images/photos' directory.
This is the directory I've set as the image_import directory.
/home/clients/html/images/photos

The images should be placed in the 'files/images' directory.
But only the Original image is placed there.
And the file I uploaded is deleted.
But the derivitives are not created.

Also note, 1.0 doesn't really work either.
But that is the last version I've used on other sites.

drewish’s picture

Earlier you said:

However, if I attach an image to a node, the alternative sizes are created.

Does this mean that when you use image_attach the derivatives are created? Or if you create a new node via node/add/image, that a the derivative images are created?

pelicani’s picture

That is correct.
I am able to create an image node as well as attach a new image to an existing node.
Without problems.
All derivatives are created.
Weird.

In my Drupal install, there is a directory named 'files'.
In the files directory is a directory named 'images' that stores the derivatives.

When I use image import, I FTP my images into another directory named 'images' that is not in the 'files' directory but in the root Drupal directory.
This is the directory that is passed to the derivatives code and it fails when is see that path.

I hope this info helps.
I've reverted to an older code base, but that isn't working right either.
I thought it was, but it isn't.
Bumber.

drewish’s picture

i wonder if it's a permissions issue. can you compare the owner of the originals of a node created by uploading and by importing?

pelicani’s picture

When I debugged the import code, the file_create_path function failed to return any path.
Which means that the derivatives will not run.
At least, that is how I read the code.
The problem with the path seems to be the thing that stops the derivatives.

It seems to expect the path for the new image in the 'files' directory.
But it is getting the old path of the ftp'd image.

echo $node->images[IMAGE_ORIGINAL]; //returns as the location of the file I uploaded
$original_path = file_create_path($node->images[IMAGE_ORIGINAL]);
echo "-".$original_path; //returns blank

drewish’s picture

Title: Only the Original » Derivative images not built when importing from outside /files

Thanks for your help tracking that down. I've been able to confirm the bug when importing files that are not within the files directory.

drewish’s picture

Status: Active » Needs review
StatusFileSize
new2.42 KB

okay, here's a patch that should fix this.

pelicani’s picture

Status: Needs review » Needs work

tweak to the patch, $size = _image_get_sizes(IMAGE_ORIGINAL, $aspect_ratio);
add the underbar to the function name for image get sizes.
also, the original ftp'd file is not being deleted.
weird, because before the patch, that was actually working.

i appreciate your work by the way.
thanks again.

drewish’s picture

Status: Needs work » Needs review
StatusFileSize
new2.36 KB

if you update to the latest version of -dev you'll find that there's now a image_get_sizes(). this should get the deletion working again.

drewish’s picture

Status: Needs review » Fixed

after some more testing i've committed the patch in #15

pelicani’s picture

Status: Fixed » Needs work

Yes, I see in the dev version there is that function.
I applied the patch and the derivatives are created correctly.
But the original is not removed.

NOTE: I also loaded your patch for rebuilding derivatives, which works wonderfully.

drewish’s picture

Status: Needs work » Fixed

the deleting of originals works fine for me, when the new -dev release is posted please test that out. also if a patch is working for you, leave a message on the issue where you found it. that sort of feedback is very valuable.

Anonymous’s picture

Status: Fixed » Closed (fixed)
rcork’s picture

Status: Closed (fixed) » Active

Bug exists in 6.x codebase

The following code at the bottom of the function image_create_node_from() in image.module fixed this problem for me

$node->new_file = TRUE;
$node->images[IMAGE_ORIGINAL] = $filepath;

// Build derivatives
$node->images = _image_build_derivatives($node, FALSE);

// Save the node.
$node = node_submit($node);
node_save($node);

Hetta’s picture

Status: Active » Closed (fixed)
joachim’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new557 bytes

Well #242341: Derivatives are not created when using Image Import is marked as a duplicate of this now...

We're actually testing for this (and failing...); see #670686: tests for programmatic image node creation fail because derivatives aren't created.

So: do we change the behaviour here (patch attached for that), or remove those tests?
It's a choice between having slow loading image nodes the first time they are seen, and a longer import process.

From the other issue:

I actually prefer the on-demand version, because although it does slow down the first gallery view (big deal), it means that my image_import process itself doesn't timeout (actually a big deal!).
Temporarily slow images in a gallery I can deal with. They turn up next time you look.

joachim’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

Version change... patch is on HEAD ;)