php2012. 9. 29. 02:52

업로드한 파일이나 이미 저장된 파일을 축소해서 썸네일을 생성하는 방법을 요약하면

1. 원본이미지를 불러온다

2. 새로이 생성될 이미지가 들어갈 집을 만든다

3. 만들어진 집에 원본이미지를 축소하여 붙여 넣는다

4. 저장한다.

예를들어 400*200 인 origin.gif 를 200*100 의 copy.gif 로 만드는 과정을 보자

// 원본 이미지 load

$path = "/images/origin.gif";

$o_img = imagecreatefromgif($path);

// 썸네일 이미지가 들어갈 집 만들기

$n_img = imagecreatetruecolor(200,100);

// 생성한 집에 원본이미지를 축소해서 넣기

imagecopyresampled($n_img,$o_img,0,0,0,0,200,100,400,200);

// 이미지 저장하기

$n_path = "/images/copy.gif";

imagegif($n_img, $n_path);

// 썸네일 생성

imagecopyresampled($n_img, $o_img, 0,0,$offsetX,$offsetY,$w,$h,$cropW,$cropH);

각각의 파라미터들은 썸네일이 될 이미지, 원본 이미지, x좌표 기준점, y좌표 기준점, x좌표, y좌표, 축소할 길이, 축소할 세로길이,

원본에서 잘라낼 가로길이, 원본에서 잘라낼 세로길이..

참 많다..

Posted by 다오나무
iOS2012. 9. 18. 15:10

지난 강좌에서는 동기식으로 이미지를 가져오는 것을 구현했습니다. 하지만 동기식으로 데이터를 가져올 경우 용량이 큰 데이터에서 앱이 멈춰버리는 현상을 발견할 수 있습니다. 이처럼 앱이 멈추는것과 같은 현상을 제거하기 위해서는 비동기식으로 데이터를 가져와야합니다. 이번 강좌에서는 비동기식으로 데이터를 가져오는 방법, 그중에서 NSThread를 이용하는 방법에 대해서 알아보겠습니다.


 비동기식으로 데이터를 읽어온다면 앱의 사용자에게 '지금은 데이터를 로딩하는 중입니다.' 라는 것을 알리기 위한 방법이 필요합니다. 그 중에서 가장 많이 사용되는 방법은 Indicator를 사용하는 방법입니다. (데이터를 로딩하면 빙글빙글 돌아가는 그것입니다.) 프로젝트의 헤더에서 아래와 같이 구성해준 후 인터페이스 빌더에서 연결해줍니다.





 본 프로젝트에서는 뷰가 로드됨과 동시에 이미지를 읽어온다고 했지만, 개발자의 사정에 맞춰서 적당한 순간에 데이터를 로드하면 되겠습니다.



 우선 뷰가 로드되고 동시에 데이터를 읽어오므로 indicator를 start 해줍니다. 대부분의 사항은 상단의 코드와 주석을 봐도 충분히 이해 될 것이라고 생각합니다. 이 방법의 기본 개념은 '같은 스레드에서 이미지를 로딩하면 데이터가 로드되는 코드에서 앱이 멈춰버리고 코드가 진행되질 않으니 데이터를 로딩하는 부분만 다른 스레드에서 실행되게 하자' 입니다. 그래서 이처럼 데이터를 로드하는 부분만 따로 메서드로 구현해줍니다.




 데이터를 로드하는 부분에서 이처럼 데이터를 로드하고 이미지를 세팅하는 것 까지 구현해줍니다. 이제 앱을 실행시키면 Indicator가 돌아가다가 이미지의 로드가 끝나게 되면 Indicator가 사라지고 이미지가 화면에 출력됩니다. 단지 데이터를 읽어오는 부분만 리팩토링하여 스레드로 실행시키기만 하면 동기식 데이터 로드가 비동기식으로 전환 되는 것입니다.

Posted by 다오나무
iOS2012. 9. 17. 13:14

This is the approach I use for iOS 4 and 5 compatibility:

if ([toolbar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) {
   
[toolbar setBackgroundImage:[UIImage imageNamed:@"toolbar-background"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
} else {
   
[toolbar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"toolbar-background"]] autorelease] atIndex:0];
}

Posted by 다오나무
iOS2012. 9. 13. 11:01

그림 1.



Corner에 라운드가 처리된 ImageView가 필요해서, 만들게 되어 이러게 공유 합니다 ^^

구글링 해보면, 이런저런 기법들이 많이 나오는데요, 복잡한 해법들이 많은데,
저는 UIBeizerPath라는 녀석을 이용해서, 간단히 구현 하는 방법을 소개 해볼까 합니다.

아직 UIImageView를 이용하면 가장 좋을것 같은데, 방법을 따로 못찾아서, UIView를 상속 받아서, 구현하였습니다.
혹시 아시는 분 있으면 공유! 부탁드립니다 !

RoundRectedImageView.h

#import <Foundation/Foundation.h>

@interface RoundRectedImageView : UIView {

}

@property (nonatomic,retainUIImage *image;

-(id) initWithImage:(UIImage *) aImage;

@end


RoundRectedImageView.m

#import "RoundRectedImageView.h"


@implementation RoundRectedImageView

@synthesize image = mImage;

-(id) initWithImage:(UIImage *) aImage {

    

    self = [super initWithFrame:CGRectMake(00, aImage.size.width, aImage.size.height)];

    self.image = aImage;

    self.backgroundColor = [UIColor clearColor];

    return self;

}


-(void) drawRect:(CGRect)rect {

    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCornerscornerRadii:CGSizeMake(16.016.0f)];

    [path addClip];

    [self.image drawInRect:rect];

}

-(void) dealloc {

    self.image = nil;

    [super dealloc];

@end


코드양이 별로 없어서, 설명도 간략하겠군요 :)
drawRect: Method만 살펴 보시면 됩니다.

1. Round가 있는 사각형 UIBezierPath Object를 만든다.
2. addClip 을 호출하여, 앞으로 그려질때, clipping 되도록한다.
3. UIImage를 그려준다.



이렇게 해주면 그림.1 의 우측 그림과 같이 RoundRect 된 ImageView가 됩니다. ^^

Posted by 다오나무
iOS2012. 9. 4. 15:45

*1번째 간단한 방법(Action 버튼 생성)*
장점 : 상당히 쉽게 만들수 있음.
단점 : 버튼이 터치되는 영역이 실제 버튼보다 훨 씬 넓음.

UIBarButtonItem *composerBtn =[[UIBarButtonItem allocinitWithBarButtonSystemItem:UIBarButtonSystemItemAction target:selfaction:@selector(composerMethode)];


*2번째 방법 : 시스템아이템 버튼이 아닌 임의의 이미지를 이용하여 버튼 구성 방법*

장점 : 버튼의 외각 이미지 + 내부 추가한 이미지(i.png)표현 가능.
단점 : 버튼이 터치되는 영역이 실제 버튼보다 훨 씬 넓음.


UIImage *image = [UIImage imageNamed:@"i.png"];

image = [UIImage imageWithCGImage:[image CGImagescale:2.0 orientation:UIImageOrientationUp];

UIBarButtonItem *editButton = [[UIBarButtonItem alloc

                                       initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(editDB)];

        

self.navigationItem.leftBarButtonItem = editButton;


*3.번째 방법 : 임의의 뷰에 UIButton을 추가하여 구성하는 방법*
목적 : 1번째,2번째 방법의 단점을 해결하고자 함.
장점 : 정확히 버튼의 크기만큼만 터치가 됨.
단점 : 시스템에 있는 버튼아이템이미지 사용 불가. , 버튼의 외각 이미지 표현 불가.

            UIView *rightview = [[UIView allocinitWithFrame:CGRectMake(0,0,25,20)];

            

            UIButton *searchbutton = [[UIButton allocinitWithFrame:CGRectMake(0,0,2520)];


            UIImage *image = [UIImage imageNamed:@"action.png"];

            image = [UIImage imageWithCGImage:[image CGImagescale:1.0 orientation:UIImageOrientationUp];

            

            [searchbutton setImage:image forStateUIControlStateNormal];


            [searchbutton addTarget:self action:@selector(composerMethode) forControlEvents:UIControlEventTouchUpInside];

            [rightview addSubview:searchbutton];

            [searchbutton release];

            

            UIBarButtonItem *composerBtn = [[UIBarButtonItem allocinitWithCustomView:rightview];

            [rightview release];

Posted by 다오나무
iOS2012. 9. 3. 17:21

UIImageView를 사용할 경우 UIImageView의 프레임 사이즈에 맞춰 이미지 비율에 따라 이미지 사이즈를 쉽게 재조정할 수 있지만

뷰상에서 특정 UIImage를 drawRect하는 경우에는 비율에 맞춰서 이미지 사이즈나 스케일을 재조정하는게 쉽지 않다.

따라서 다음과 같은 UIImage의 카테고리를 사용해 이미지 비율에 따라 UIImage스케일을 재조정한다.



카테고리의 헤더 파일 

#import <Foundation/Foundation.h>


@interface UIImage (UIImageSizeExtention)


- (UIImage *)fixImageSize;

- (UIImage *)fitToSize:(CGSize)newSize;

- (UIImage *)scaleToSize:(CGSize)newSize;

- (UIImage *)scaleProportionlyToWidth:(CGFloat)width;

- (UIImage *)scaleProportionlyToHeight:(CGFloat)height;

- (UIImage *)cropToRect:(CGRect)newRect;


@end   


카테고리의 실행 파일

#import "UIImage+SizeExtention.h"


@implementation UIImage (UIImageSizeExtention)
 

#pragma mark -

#pragma mark Basic


- (UIImage*)fixImageSize 

{

    // Fix some strange bug

    UIGraphicsBeginImageContext(self.size);

    [self drawInRect:CGRectMake(00self.size.widthself.size.height)];

    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return newImage;

}


#pragma mark -

#pragma mark Fit (Combination)


- (UIImage *)fitToSize:(CGSize)newSize {

    float originalProportion = self.size.width/self.size.height;

    float targetProportion = newSize.width/newSize.height;

    float scaleProportion = newSize.width/self.size.width;

    UIImage *targetImage;

    

    if (targetProportion == originalProportion) {

        // Same Proportion

        // Do not have to crop, Direct scale

        targetImage = [self scaleToSize:newSize];

    } else if (targetProportion) {

        // Relative Landscape

        // Crop Rect

        CGFloat originX = self.size.width*scaleProportion/2 - newSize.width/2;

        CGRect cropRect = CGRectMake(originX, 0, newSize.width, newSize.height);

        // Scale to Height, Crop

        targetImage = [[self scaleProportionlyToHeight:newSize.heightcropToRect:cropRect];

    } else {

        // Relative Portrait

        // Scale to Width

        CGFloat originY = self.size.height*scaleProportion/2 - newSize.height/2;

        CGRect cropRect = CGRectMake(0, originY, newSize.width, newSize.height);

        targetImage = [[self scaleProportionlyToWidth:newSize.widthcropToRect:cropRect];

    }

   

   return targetImage;

}

               

#pragma mark -

#pragma mark Scale

               

- (UIImage *)scaleToSize:(CGSize)newSize {

    UIImage *targetImage = [self fixImageSize];

    // Prepare new size context

    UIGraphicsBeginImageContext(newSize);

    // Get current image

    CGContextRef context = UIGraphicsGetCurrentContext();

   

    // Change the coordinate from CoreGraphics (Quartz2D) to UIView

    CGContextTranslateCTM(context, 0.0, newSize.height);

    CGContextScaleCTM(context, 1.0, -1.0);

    // Draw (Scale)

    // The size of this drawRect is for scale

    CGRect drawRect = CGRectMake(00, newSize.width, newSize.height);

    CGContextDrawImage(context, drawRect, targetImage.CGImage);

   

    // Get result and clean

    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

   

    return scaledImage;

}


- (UIImage *)scaleProportionlyToWidth:(CGFloat)width {

    float originalProportion = self.size.width/self.size.height;

    CGFloat height = width/originalProportion;

    return [self scaleToSize:CGSizeMake(width, height)];

}


- (UIImage *)scaleProportionlyToHeight:(CGFloat)height {

    float originalProportion = self.size.width/self.size.height;

    CGFloat width = height*originalProportion;

    return [self scaleToSize:CGSizeMake(width, height)];

}

               

#pragma mark -

#pragma mark Crop

               

- (UIImage *)cropToRect:(CGRect)newRect {

    UIImage *targetImage = [self fixImageSize];

    // Prepare new rect context

    UIGraphicsBeginImageContext(newRect.size);

    // Get current image

    CGContextRef context = UIGraphicsGetCurrentContext();

   

    // Change the coordinate from CoreGraphics (Quartz2D) to UIView

    CGContextTranslateCTM(context, 0.0, newRect.size.height);

    CGContextScaleCTM(context, 1.0, -1.0);

    // Draw (Crop)

    // This drawRect is for crop

    CGRect clippedRect = CGRectMake(00, newRect.size.width, newRect.size.height);

    CGContextClipToRect(context, clippedRect);

    CGRect drawRect = CGRectMake(newRect.origin.x*(-1), newRect.origin.y*(-1), targetImage.size.width, targetImage.size.height);

    CGContextDrawImage(context, drawRect, targetImage.CGImage);

   

    UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return croppedImage;

}    

@end



위의 카테고리를 다음과 같이 사용하였다.

UIImage *image = [UIImage imageNamed:/*Image name*/];


if
 (image.size.width > image.size.height

{

// If the width of a image is longer than the height
// rescale to width

image = [image scaleProportionlyToWidth:/*Image width*/];

}

else

{        

// If the height of a image is longer than the width
// recale to height

image = [image scaleProportionlyToHeight: /*Image height*/];

}


CGRect drawRect = CGRectMake(0, 0, image.size.width, image.size.height);


[image drawInRect:drawRect];


Posted by 다오나무
iOS2012. 8. 27. 17:52

UITableView에서 각 cell 마다 이미지를 로드하거나 특정 시점이 아닌 비동기적으로 이미지를 로드하기 위한 방법이 필요할 때가 있다. 이미지 로드가 완료될때까지 기다렸다가 다음 프로세스를 진행하게 되면 UI가 멈추거나 인터렉티브한 프로그램을 만드는데 많은 제약이 생기기 때문이다. 이러한 이유로 이전부터 비동기 형식으로 이미지를 로드하는 방법과 예제가 블로그와 책에 소개가 많이 되어왔다. 이러한 비동기 방식으로 이미지 로드는 iPhone 로컬의 이미지를 로드하기보다 원격지에 있는 URL을 이용해서 이미지를 로드할때 그 필요성이 더 필요하다. 네트워크를 통해서 이미지를 가져온다는 것은 바이너리 이미지를 로드하는 시간보다 네트워크에서 데이터를 전송하는 시간이 더 많이 걸리기 때문이다. 만약 원격 이미지를 비동기 방식으로 로드하지 않게 되면 UI가 멈추어 버리기 때문에 사용자들은 앱이 죽었다고 생각하거나 답답해서 그 앱을 두번다시 사용하지 않을지도 모른다.

비동기 방식으로 이미지를 로드하는 예제들
http://developer.apple.com/library/ios/#samplecode/LazyTableImages/index.html
http://www.markj.net/iphone-asynchronous-table-image/
http://gazapps.com/wp/2011/06/29/asynchronous-images-on-ios/ 
http://avishek.net/blog/?p=39

위에서 사용하는 방법은 NSURLConnection을 이용해서 delegate method를 이용하는 방법을 보통 사용한다. delegate pattern은 작업 처리를 하는 객체에게 위임을하거나 비동기적으로 객체에 메소드를 호출할때 매우 유용한 방법이다. 하지만 delegate를 사용하면 delegate 메소드가 필요하게 되고 delegate 메소드 안에서 처리할 작업을 정의해 두어야 한다. 

이미지를 비동기 방식으로 로드하고 비동기 방식으로 로드하면서 외부에서 그 이미지를 처리하는 메소드까지 선언해줄수 있는 방법으로 block과 GCD (grand centeral dispatch)를 이용하는 방법을 참조하였다. block은 Python이나 Ruby 등에서 사용하는 closure 개념과 비슷하다. Block은 C 레벨의 문법과 런타임 특징이다. 이것은 C의 기본 함수와 비슷하지만 실행가능한 코드를 추가할 수가 있고 stack 또는 heap 메모리를 바인딩하는 변수를 포함할 수 있다. 이러한 특징 대문에 Block은 실행되는 동안에 어떠한 행위를 위해서 데이터의 상태를 유지할 수 있는 특성을 가진다. Block에 관해서는 다시 한번 Block의 주제에 관해서 다시 포스팅을 할 예정이다. GCD는 애플에서 개발한 기술로써 멀티코어 프로세서에 최적화된 어플리케이션을 지원하기 위해서 만들어진 기술이다. GCD는 병렬처리와 쓰레드 풀을 기반한 기술이다. GCD에 대한 상세한 내용역시 다른 포스팅으로 준비 중이다. Block과 GCD를 이용하면 기존에 사용하던 방법(delegate로 처리하는 방법)과는 다르게 원하는 방법을 구현할 수 있을 것이라는 생각을 가지고 검색해서 다음 블로그를 찾을 수 있게 되었다.  http://www.geekygoodness.com/2011/06/17/uiimage-from-url-simplified/  이 블로그에서는 아주 간단한 설명만 남겨 두었지만 Block과 GCD를 이용해서 이미지를 로드하는 방법을 소스코드로 잘 표현해 주고 있다. Block은 iOS4 이상에서만 사용이 가능하다.

void UIImageFromURL( NSURL * URL, void (^imageBlock)(UIImage * image), void (^errorBlock)(void) )

{

    dispatch_asyncdispatch_get_global_queueDISPATCH_QUEUE_PRIORITY_DEFAULT0 ), ^(void)

                   {

                       NSData * data = [[NSData allocinitWithContentsOfURL:URL];

                       UIImage * image = [[UIImage allocinitWithData:data];

                       dispatch_asyncdispatch_get_main_queue(), ^(void){

                           if( image != nil )

                           {

                               imageBlock( image );

                           } else {

                               errorBlock();

                           }

                       });

                   });

}

 

이 코드를 iOS에서 사용하면 다음과 같은 warning이 나타난다.


이것은 UIImageFromURL가 미리 선언되어 있지 않아서 발생하는 경고인데 .h 파일 안에 미리 선언해주면 이 경고는 사라진다.

#import <UIKit/UIKit.h>


@interface ViewController : UIViewController


void UIImageFromURL( NSURL * URL, void (^imageBlock)(UIImage * image), void (^errorBlock)(void) );

@end


사용방법은 참조한 블로그에 나온 방법대로 사용하면 되는데 다음과 같이 사용하면 된다.

- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

    

    UIImageFromURL( [NSURL URLWithString:@"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331"], ^(UIImage * image )

    {

        [self.view addSubview:[[UIImageView allocinitWithImage:image]];

    }, ^(void){

        NSLog(@"%@",@"error!");

    });


}



우리는 이 코드를 좀더 Objective-C에 익숙한 메소드와 파라미터 방식으로 변경하고 싶다고 생각했다. Objective-C의 메소드 선언 방법은 개발할때 파라미터에 대한 이름과 타입을 참조하는데 더 유용하기 때문이다. 그래서 이 코드를 다음과 같이 변경하여 인스턴스 메소드로 만들어서 사용할 수 있다. 

#import <UIKit/UIKit.h>


@interface ViewController : UIViewController


//void UIImageFromURL( NSURL * URL, void (^imageBlock)(UIImage * image), void (^errorBlock)(void) );


- (void) loadAsyncImageFromURL:(NSURL *)url  imageBlock:(void (^) (UIImage *image))imageBlock errorBlock:(void(^)(void))errorBlock;

@end


- (void) loadAsyncImageFromURL:(NSURL *)url  imageBlock:(void (^) (UIImage *image))imageBlock errorBlock:(void(^)(void))errorBlock

{

    dispatch_asyncdispatch_get_global_queueDISPATCH_QUEUE_PRIORITY_DEFAULT0 ), ^(void)

                   {

                       NSData * data = [[NSData allocinitWithContentsOfURL:url];

                       UIImage * image = [[UIImage allocinitWithData:data];

                       dispatch_asyncdispatch_get_main_queue(), ^(void){

                           if( image != nil )

                           {

                               imageBlock( image );

                           } else {

                               errorBlock();

                           }

                       });

                   });

}


- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.


    [self loadAsyncImageFromURL:[NSURLURLWithString:@"https://t1.daumcdn.net/cfile/tistory/1349CD374EA43DFB2E"

                     imageBlock:^(UIImage *image){ 

                         [self.view addSubview:[[UIImageView allocinitWithImage:image]];

                     } 

                     errorBlock:^(void){

                         NSLog(@"%@"@"error!");

                     }];


    

//    UIImageFromURL( [NSURL URLWithString:@"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331"], ^( UIImage * image )

//    {

//        [self.view addSubview:[[UIImageView alloc] initWithImage:image]];

//    }, ^(void){

//        NSLog(@"%@",@"error!");

//    });



이 방법을 이용해서 테이블에 이미지를 비동기 방식으로 로드하는 예제를 작성하면 다음과 같이 될 것이다. 간단하게 테이블에 URL 문자열을 가지는 items 배열을 가지고 사용하였지만, 실제 사용할때는 이 데이터 역시 json이나 xml에서 받아와서 만들 것으로 예상이 된다. tableView:cellForRowAtIndexPath: 메소드에서 cell의 작업을 할때 우리는 비동기 방식으로 처리하는 이 코드로 작업을 처리할 수 있다. 
(이 예제는 정말 단순하고 간단한 예제 이다. 더욱 좋은 코드를 만들기 위한 방법을 이 포스트에서는 소개하지 않는다.)

- (void)viewDidLoad

{

    [super viewDidLoad];


    items = [[NSArray allocinitWithObjects:@"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331"

             @"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331",

             @"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331",

             @"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331",

             @"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331",

             @"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331",

             @"https://t1.daumcdn.net/cfile/tistory/186A3A384EEAE04331",

             nil];

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *CellIdentifier = @"Cell";

    

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[UITableViewCell allocinitWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier];

    }

    

    // Configure the cell...

    [self loadAsyncImageFromURL:[NSURL URLWithString:[items objectAtIndex:indexPath.row]] 

                     imageBlock:^(UIImage *image){ 


                         [[cell.contentView viewWithTag:999+indexPath.rowremoveFromSuperview];

                         

                         UIImageView *imageView = [[UIImageView allocinitWithImage:image];

                         imageView.frame = CGRectMake(04.0f.0f44.0f44.0f);

                         imageView.tag = 999+indexPath.row;

                         

                         [cell.contentView addSubview:imageView];

                     } 

                     errorBlock:^(void){

                         NSLog(@"%@"@"error!");

                     }];

    cell.textLabel.text = [items objectAtIndex:indexPath.row];

    return cell;

}

 


참조 원문 : http://www.geekygoodness.com/2011/06/17/uiimage-from-url-simplified/
코드의 저작권은 http://www.geekygoodness.com 에 있기 때문에 코드 사용시 원 저작권자에게 사용 요청을 받기 바랍니다.

Posted by 다오나무
php2012. 7. 25. 05:26

descript)
    youtube에 올린 동영상을 등록하는 이벤트를 진행 
    youtube에 동영상을 올리면 youtube에서 섬네일을 생성해주므로 그를 사용하면되지만 
    다른크기의 이미지를 요구 youtube의 이미지를 가져올 필요


source)
    Snoopy.class.php 파일을 설치한후 이를 이용해서 저장 

    $snoopy = new Snoopy;
    $snoopy ->referer = "http://img.youtube.com";
    $snoopy -> fetch( "http://img.youtube.com/vi/".{유튜브동영상키값}."/0.jpg" );
    $content = $snoopy -> results;

    $newFile = fopen( {저장할위치} ,"wb"); 
    fwrite($newFile, $content); 
    fclose($newFile);

Posted by 다오나무
iOS2012. 6. 20. 21:10

제목그대로 인데요

아이폰에서 탭바를 사용시에

탭을 4개 넣을껀데요

그 하나하나당 이미지를 넣을껀데 그 이미지에 사이즈가 최대사이즈가 얼마가 들어갈수있는건가요?


developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html


아래주소로 가보면 


30 x 30  이 기본이고 60 x 60 이 높은퀄리티인거 같은데...

탭바아이템 하나하나가 정사각형이 아니고 직사각형 모양인데...기준은 저렇게 적혀있어서

탭바를 4개 넣을시에 최대사이즈를 알고싶습니다..

76x48 정도로 잡아서 해봤었는데 이미지가 삽입되는데 아랫부분이 잘려서 들어가지더라구요...

(이것도 좀 의문입니다...분명 가로크기를 기준에서 벗어났는데 들어가진걸보면...)

도움좀 주세요~


Posted by 다오나무
기타2012. 5. 21. 00:59




iPhone 에서 작성된 글입니다.

'기타' 카테고리의 다른 글

강남 파이낸스 빌딩 밤  (0) 2012.05.21
여의도 옥상  (0) 2012.05.21
marsEdit Test  (0) 2012.05.20
오 ecto 테스트중  (0) 2012.05.20
맨인블랙3  (0) 2012.05.19
Posted by 다오나무