The image cannot be opened in python 3.6 - windows

I got question about the remote sensing image cannot be opened in Spyder(python 3.6), however, the weird thing is there are two "tif" files (Image.tif and Trend.tif) in the same directory and the Trend.tif which is the classification result of the Image.tif can be open with the code like this:
img= Image.open('C:/zijianwang/Final/2/Trend.tif')
but when I change the name to:
img1= Image.open('C:/zijianwang/Final/2/Image.tif')
I got the error:
OSError: cannot identify image file 'C:/zijianwang/Final/2/Image.tif'
Can somebody know what's going on here? Thank you so much!

My current PIL version is 4.2.1 and it is working for me. My code is as follows:
from PIL import Image
img = Image.open("{image-folder-path}/Trend.tif")

Related

I cant make a dynamic image path in pdf

I've been trying to display an image in a fpdf file, it only works when I specify the exact location of the image. Can I make it dynamic?
Heres sample line of code:
$this->Image('fpdf/img/logo1.png',10,6,30);
and it works when I turn this way:
D:\Installed Apps\New
folder\XAMPP\htdocs\votingsystem\application\views\admin\senior\fpdf\img\logo1.png',10,6,30);
I want to transfer it to another laptop, I'm afraid it wont work.
I always get this error:
Message: fopen(fpdf/img/logo1.png): failed to open stream: No such
file or directory
I use code igniter as framework.
You can use multicell option in fpdf. I use this below code in php to it working.
`
define('ASSETS_URL','Your url or path to image file');
$yaxix = $pdf->GetY();
$xaxix = $pdf->GetX();
$pdf->MultiCell(50,10.5,$pdf->Image(ASSETS_URL.'/img/your-image-name.jpg',$xaxix,$yaxix+5,50)."\nAuthorised Signatory",1,'C',FALSE);
`
In this case you only have to change constants.

Python 3 Couldn't open "<folderdirectoryhere>" : permission denied

Hoi! I was trying to access an image of mine using the following code:
import tkinter as tk
root = tk.Tk()
image = tk.PhotoImage(file="C:\\Users\*<mynamehere>*\\Documents\\Platformer")
label = tk.Label(image=image)
label.pack()
root.mainloop()
But I got the error stated in the title.
What's wrong, and how can I fix it? Any tips to load images in the future?
put an "r" before the file to open the raw file
image = tk.PhotoImage(file=r"C:\\Users\*<mynamehere>*\\Documents\\Platformer")

Three.JS plugin for Blender not working

I cannot install the Three.js plugin for Blender. I have a Fedora with Blender 2.69, I created the directory io_mesh_threejs in /usr/share/Blender ... /addon and copied the 3 .py files into but the plugin doesn't appear in the user preference.
I also tried with a downloaded 2.65 version of Blender with no success.
I did it for another library (Babylon.js) and it worked fine so I guess it comes from the python files ?
Here is what I did to get it to work with Win 7 - may work for you also.
Make sure you copy the text from the Raw File format instead of just right clicking and downloading the python files. If you right click and download you might get some additional html code that will break it. Someone else here made that suggestion previously.
Put the import and export files in the io_mesh_threejs folder. Put the init file in the root of the addons directory.
That did the trick for me anyway.
hopefully this adds to the conversation stream ... I've spent two hours finding this answer myself for IFC file imports for Blender ... I've just now got there ... I'm on a Mac with OSX and my Blender 2.71 is positioned in /Users/username/Documents/Blender ... I tried the User Preferences to no avail ... even followed the PATH to /Users/username/Library/Application Support/Blender/2.71/scripts/addons and manually copied the files in using shell ... still nothing ... then I found that the actual place they should go is
/Users/username/Documents/Blender/blender.app/contents/MacOS/2.71/scripts/addons
In my case for IFCBlender I then made a directory called
bash$ mkdir io_scene_ifc
Then I copied in the all the downloaded files ... Hooray this now appeared in my User Preferences ...

Missing xml tag SVG file (using Graphviz dot.exe)

My config is:
- Windows Vista
- XAMPP 1.7.1
- Media Wiki + Semantic MW
- an extension that uses Graphviz to create a SVG
- Graphviz 2.26.3 (install dir c:\graphviz.....)
Everything works fine but the problem is: the xml tag
'image xlink:href="some_image.png"....'
is missing from the SVG file created using a Media Wiki php page.
This is done by:
$cmdlinesvg = wfEscapeShellArg($cmd).' -T svg '.wfEscapeShellArg($src).' -o '.wfEscapeShellArg($svg);
$WshShell = new COM("WScript.Shell");
$WshShell->Exec($cmdlinesvg);
I've created a batch file that executes the same command line:
c:\graphviz2.26.3\bin\dot.exe -T svg filename.dot -o filename.svg
and if I run it manually it works, and the xml tag appears.
Anyone knows what is the problem? thanks in advance.
SOLVED
The problem is related to the image path that is in the .DOT file.
If you run the command line manually, the image path doesn't need to be a full path.
You can have only: shapefile="some_image.png"
If you run the command inside php code, the image path HAS to be a full path.
So you must have: shapefile="C:\xampp......\some_image.png"
Another problem arises: the resulting .SVG file doesn't show the images.
If you right-click and open the .SVG file with the browser (ie Firefox), the images are ok.
But, again, through a php page, the images are lost.
Solution: edit the .SVG file (this is XML) to change the paths.
On the original .SVG file we have:
On the modified .SVG file we must have:
PS: I'm doing my master thesis, so this is for a particular problem, but still I hope it helps someone.

How does MediaWiki calculate the file path to an image?

I'm just installing MediaWiki (loving it). I'm lookin at this for adding images. I can se the logic of
[[File:MediaWiki:Image sample|50px]]
but where so I set the filepath for "File" (nothing obvious in LocalSettings.php) ... or is there some other logic at work?
I'd appreciate any help
Thanks
File location is determined by $wgLocalFileRepo which by default depends on $wgUploadDirectory and $wgHashedUploadDirectory. The upload directory defaults to [MediaWiki base dir]/images (Adrian must be using an older version). If hashing is enabled, /x/xy will be appended to the path, where xy are the first two letters of the md5 hash of the filename.
The defaults from DefaultSettings.php are:
$wgUploadPath = "$wgScriptPath/uploads";
$wgUploadDirectory = "$IP/uploads";
If you want to change this, you should copy and paste this into LocalSettings.php
And make sure that $wgEnableUploads = true; is in LocalSettings.php too.
Your "Image sample" is the name of image, not the name of a file. By config file you can just set the root folder for image uploads.
Just for future reference in case someone else runs into this issue:
I installed MediaWiki on my Mac OS Sierra and when I attempted to upload an image I got the following message:
Failed:
Could not open lock file for "mwstore://local-backend/local-public/d/d9/babypicture.png".
I changed the permissions on the mediawiki_root/images folder to be owned by _www user and group.
chown -R _www:_www wiki/images
I was able to upload the image afterward.

Resources