SKTexture: Error loading image resource - ios

This seems to work perfectly fine:
and when I created a new project with exactly the same thing, just new images, it doesn't work:
I even tried
var mainChartxt = SKTexture(imageNamed: "mainC.png")
and it still gives me the same error:
SKTexture: Error loading image resource: "img/mainC.png"
I tried cleaning the project and deleting the derived data folder and still no luck as the image doesn't show up on the app!
Thanks.

Where / How did you add the image in your project ?
The second syntax (without the path) should be ok. You don't even have to specify .png if that's the file format (but you need to if it something else : .jpg, .jpeg, ...
You might want to check that your asset is "checked" for the target membership. On the right side (Utilities) > File Inspector > Target Membership : check your target (not the tests one if you don't have any tests).

A similar error occurred to me while following a tutorial to develop a game using spritekit.
Error was "SKTexture: Error loading image resource:"imagename""
In my case the path was not set properly.
We can recheck to be sure that the path is always set correctly.

Related

cordova-plugin-file: files not accessible after app update (iOS)

I am experiencing a funny problem: I am developing an ionic app, using cordova-plugin-file to store images. The resulting paths (URIs in form file:///...) are stored in a SQLite DB along with more information. When I install the app and use it, all works perfect. But if I update (or reinstall) the app, the old images are not found anymore, while newly added images work perfect.
I first suspected that the image files were being deleted on update, but I checked the content of the directory and the files are still there. (FYI: I am using file.dataDirectory/scans/ to place my files).
Then I thought that maybe I could go around the problem loading into img src a base64 blob loaded with cordova.file.readAsUrl(), but cordova.file does not find the file as well (I insist, the files are there, I checked with XCode).
So I checked further with cordova.file and it only finds files that are added after last app install, but the older files are still present in the directory.
Here my code:
private getImgSrcFromDocument(doc: Document): any {
const uri = doc.fileName;
const src = this.webView.convertFileSrc(uri);
const sanitized = this.sanitizer.bypassSecurityTrustUrl(src);
console.log({uri, src, sanitized});
return sanitized;
}
<img class="document_thumbnail" [src]="getImgSrcFromDocument(doc)">
I have already checked this, but is not my case.
By the way, the same code works perfect on Android.
Any idea what could be the problem?
Thanks in advance!
I found the reason why and the solution (very obvious when you know the problem):
Reason
On every new install, iOS renames the data directory for the app. The directory path has this form:
file:///var/mobile/Containers/Data/Application/ABC0000-1234-99DD-00FA-E835FEA/Library/NoCloud/
The hash in the middle is renewed on every install, so the stored full paths in DB are not valid anymore.
Solution
If you still can do it (no deploy yet, no real users), store only the relative path and complete it every time with this.file.dataDirectory (or wherever you wanted to store your files).
If you already have real users and want your update to 'find the files', just ignore the first part of the stored path and build it like before:
const ValidUri = this.file.dataDirectory + // The injected cordova-plugin-file
'relativeSubDirectories/' + // If you store your files in some subdirectory
this.document.storedFullPath.substr( // Take from fullPath only the filename
this.document.storedFullPath.lastIndexOf('/') + 1
);
Where storedFullPath is the string file:///var/mobile/....
After that, you still have to do the webView conversion and the sanitizing, like in the question above.
Hope this helps someone.

<lang>.traineddata not found ( even when it's in the correct folder)

I'm using tesseract to detect text in spanish in some screenshot of a game, I had some issues with the "spa.traineddata" so I started to train my own data called "spa1.traineddata" and I used the two files to make text detection more accurate, yesterday I make some tests and seemed to work well, but the file "spa1.traineddata" needed more training, so I decided to continue today, I added some new images to train my file "spa1.trainneddata" and then I wanted to test it and throws me the following error
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:\\Program Files\\Tesseract-OCR/tessdata/-l spa.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'-l spa\' Error opening data file /home/debian/src/github/tesseract-ocr/tesseract/bin/ndebug/x86_64-w64-mingw32-5.0.0-alpha.20200223/usr/x86_64-w64-mingw32/share/tessdata/spa1 --psm
6.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'spa1 --psm 6\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')
and these are the lines of code that I use for testing
custom_config = r'-l spa+spa1 --psm 6'
pytesseract.image_to_string(Image.open('imagenes/obv.png'), lang=custom_config)
I was searching and found that the error was because the lang.traideddata files were not in the tessdata folder, but mine are in the folder (That's why I was able to work with them yesterday)
I attach a screenshot of the tessdata folder, the last two files are the traineddata
tessdata folder
also, it is useful I'm using vscode, python 3.7 and tesseract 4
I hope you can help me (sorry my bad english uwu)

SpriteBuilder image file not found

I have added a .png image in sprit builder resource folder and I have published it.
I see the added image in sprite builder all folder in Resources under Published-IOS.
Here I have tried to access the added image in following ways.
_hero.spriteFrame = [CCSpriteFrame frameWithImageNamed:#"Down.png"];
[_hero setTexture:[CCTexture textureWithFile:#"Game/Down.png"]]
But none of these methods are working.
it show error in log as.
-[CCFileUtils fullPathForFilename:contentScale:] : cocos2d: Warning: File not found: Down.png
Please help me with this to resolve.Am a newbie using this sprit builder.
Change #"Down.png" to #"Resources/Down.png" because you have to include the folders created in SpriteBuilder for any references to resource files managed by SpriteBuilder.
Likewise if you had some.ccb in a subfolder named "Levels" you'd have to load it with the string #"Levels/some.ccb".

Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed

I have a .swf file which throws this error when I attempt to load it in a browser. Similar to other posts here this is the code:
var mySpite:Sprite = new Sprite();
var button:Loader = new Loader();
var url:String = "images/btnImage.png";
var urlReq:URLRequest = new URLRequest(url);
button.load(urlReq);
....
When I run the actionscript in Flex Build it works fine. Also when I double click the .swf file in the folder where it is stored, it works fine. I don't know why it only doesn't work and throws this error when I load it in a .jsp page.
It's most likely an issue with your path. Remember that the path to the image will be relative to the page which embeds the SWF.
In answer to your comment about having to change the paths when deploying, depending on how you're building and debugging your SWF, it might be possible to use Capabilities.playerType (see docs) to choose the correct path for the current environment. Another alternative might be to put all your image references in a couple of XML files (one local and one remote). As long as the path to the XML file is consistent between local and remote environments, you can update the SWF without worrying about the image paths.

nicEdit Uploading Locally - Issues with nicUpload

If anyone has managed to get locally uploading images I'd be mightily appreciative of some help.
I've downloaded the latest version of nicEdit along with the nicUpload plug in (from nicedit.com - Version 0.9 r24 released June 7th, 2012).
I've also downloaded nicUpload.php from http://svn.nicedit.com//trunk/nicUpload/php/nicUpload.php
NicUpload.php - I've set NICUPLOAD_PATH and NICUPLOAD_URI both to 'images' which is the subfolder of where nicupload.php and nicEdit.js are located.
NicEdit.js - I've added the following to line 271:-
uploadURI : 'nicUpload.php?id=123',
I've given it an ID otherwise it was failing with an invalid ID code. But the ?id=123 isn't meant to be there. I've also set the iconsPath accordingly.
Line 1370 I've switched this:-
nicURI : 'http://api.imgur.com/2/upload.json',
for this:-
nicURI : 'http://www.mydomain.com/nicedit/nicUpload.php',
But I'm still getting "Failed to upload image". I've searched and searched and searched for answers to this and I'm getting close to having spent two days tinkering with it.
With a few debugging displays I can see that it's failing on line 46 of nicUpload.php where it says:-
$file = $_FILES['nicImage'];
$image = $file['tmp_name'];
$max_upload_size = ini_max_upload_size();
if(!$file) {...
That last IF is true and that's where it exits with the error.
Appreciate anyone being able to help.
The nicUpload.php script file laying around sucks and I don't even understand how it could work.
NicEditor uses imgur as the default image upload service. The source code follows the API format described here: http://api.imgur.com/resources_anon#upload
My suggestion would be to implement the API request and response defined there.
I did not use the niceedit upload function to do what you want. I managed to add a button to the link and img dropdown menu. The button opens a file manager window where you also can upload. I managed to put then de url of the image or document into the nicedit drop down img or url window. That is how I solved the problem.

Resources